GitXplorerGitXplorer
j

heredoc

public
53 stars
4 forks
0 issues

Commits

List of commits on branch master.
Unverified
c1d63a1de18387c08853bcfdbebad0013e11a3ab

Merge pull request #14 from dotnil/upgrade-oceanifier

jjunosuarez committed 9 years ago
Unverified
4d9dbb2727f9f49c9049999351bea43def5094e1

Fix: make test/runner.js work in both node and browser

ccyjake committed 9 years ago
Unverified
54be492f58013a5e048b8f44f39dbf519d6117e0

Upgrade: use oceanifier@4.0.1 to simplify test/runner.html

ccyjake committed 9 years ago
Unverified
f6fc5340c4362167ded8aea51c9525153006ec82

1.3.1

jjunosuarez committed 10 years ago
Unverified
2a9f321d82d8c2081b47fcb5c4474d9e0f59d0c9

add badges

jjunosuarez committed 10 years ago
Unverified
a922d8e21e38055c2d6a056496201288505eedd5

update linting to standard

jjunosuarez committed 10 years ago

README

The README file for this repository.

heredoc

multiline strings for javascript

js-standard-style Circle CI

usage

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

    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:

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:

$ 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

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