Giter Club home page Giter Club logo

node-here.js's Introduction

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

node-here.js's People

Contributors

cho45 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

pygy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.