Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cho45/node-here.js
Here-document on node.js
https://github.com/cho45/node-here.js
heredoc javascript nodejs
Last synced: 3 months ago
JSON representation
Here-document on node.js
- Host: GitHub
- URL: https://github.com/cho45/node-here.js
- Owner: cho45
- Created: 2012-08-26T23:52:32.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-29T19:59:08.000Z (over 7 years ago)
- Last Synced: 2024-09-22T10:47:55.300Z (4 months ago)
- Topics: heredoc, javascript, nodejs
- Language: JavaScript
- Size: 109 KB
- Stars: 13
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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
*/); //=> '\\foo\\bar\\baz'
```In this case, string `*/` can not 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 have `unindent()` utility method which removes indent in a string.
```
here(/*
foo
bar
baz
*/).unindent()
```is converted to following:
```
foo
bar
baz
```LICENSE
=======MIT: http://cho45.github.com/mit-license