here
here-document on node.js
Last updated 12 years ago by cho45 .
MIT · Repository · Original npm · Tarball · package.json
$ npm install here 
SYNC missed versions from official npm registry.

node-here.js

https://github.com/cho45/node-here.js

node-here.js is here-document feature for node.js.

SYNOPSYS

This is implemeneted with block comment syntax.

var here = require('here').here;

var string = here(/*
  foo
  bar
  baz
*/);

DESCRIPTION

here(/* document */)

here function returns block comment on argument as string like object.

Escape character

Any characters can be escaped by backslash \ like following:

here(/*
  /\* *\/
*/); //=> '/* */'

here(/* \\ */); //=> '\\'

WYSIWYG

If a here document starts with ''/*, it is wysiwyg mode which does not translate any escape characters.

here(''/*
  \foo\bar\baz
*/); //=> '\\fooo\\bar\\baz'

In this case, string */ can be apeared in here document.

Returning value

here() returns not string but String object. That is like following:

var a = here(/* foobar */);
typeof a === 'object';

a.valueOf(); //=> 'foobar'
"Hello, " + a; //=> 'Hello, foobar';

Method unindent();

Returning String object hav unindent() utility method which removes indent in a string.

here(/*
  foo
    bar
  baz
*/).unindent()

is convert to following:

foo
  bar
baz

Current Tags

  • 0.0.2                                ...           latest (12 years ago)

2 Versions

  • 0.0.2                                ...           12 years ago
  • 0.0.1                                ...           12 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE