# heredoc

> multiline strings for javascript

Latest version **1.3.1** (published 2015-06-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install heredoc
pnpm add heredoc
yarn add heredoc
bun add heredoc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2015-06-10 |
| First published | 2012-12-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Author | jden |
| Maintainers | jden |
| Keywords | multiline, string, heredoc, literal |

## Links

- npm: https://www.npmjs.com/package/heredoc
- Repository: https://github.com/jden/heredoc
- Issues: https://github.com/jden/heredoc/issues
- npm.io page: https://npm.io/package/heredoc

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.3.1 (latest) — 2015-06-10
- 1.3.0 — 2015-01-13
- 1.2.0 — 2013-07-29
- 1.1.0 — 2013-03-10
- 1.0.0 — 2012-12-29

## README

# heredoc
multiline strings for javascript

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) [![Circle CI](https://circleci.com/gh/jden/heredoc.svg?style=svg)](https://circleci.com/gh/jden/heredoc) 


## usage

this technique takes advantage of `Function.prototype.toString()`

```js
    var heredoc = require('heredoc')
    var str = heredoc(function () {/*
    within this comment block,
    any text
    will
      be
        treated
          as
      pre-formatted
        multiline text
    (kinda like html <pre>)
    */})
    console.log(str)
```

You can also strip leading indentation:

```js
var text = heredoc.strip(function() {/*
      <body>
        <p>indented strings are fine.</p>
        <p>the preceding spaces will be shrinked.</p>
      </body>
    */})
```

will result in:

```
<body>
  <p>indented strings are fine.</p>
  <p>the preceding spaces will be shrinked.</p>
</body>

```

## AMD

`heredoc` defines itself as an AMD module for use in AMD environments.

## installation

    $ npm install heredoc

## testing

Install all dependencies:

```bash
$ npm install
$ npm test        # run tests in node
$ npm run test-browser       # start a server to run tests in browser
$ open http://localhost:5000/test/runner.html
```

## contributors

  - jden <jason@denizac.org>
  - Jason Kuhrt <jasonkuhrt@me.com>
  - Guy Bedford <guybedford@gmail.com>
  - Jake Chen <jakeplus@gmail.com>

## kudos

thanks to @izs - I first saw this technique when reading through npm source. I find it to be much neater than lots of manual string concatenation.

## license
ISC

---
_Source: https://npm.io/package/heredoc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
