Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/unclechu/node-njst

Node.JS: nJSt (Native JavaScript Templates)
https://github.com/unclechu/node-njst

Last synced: about 1 month ago
JSON representation

Node.JS: nJSt (Native JavaScript Templates)

Awesome Lists containing this project

README

        

# nJSt (Native JavaScript Templates)

## Installing

npm install njst

## Usage

### HTML page.html



#{PageTitle}


#{PageTitle}


    <# List.forEach(function (item) { #>
  • #{item}

  • <# }) #>

<# if (ShowMessage) { #>

nJSt loves you!


<# } #>

### Node.JS test.js

var njst = require('njst');
var fs = require('fs');
var http = require('http');

http.createServer(function (request, response) {
fs.readFile('./page.html', function (err, data) {
if (err) {
res.writeHead(500, {'content-type': 'text/html; charset=utf-8'});
res.end(err.toString());
}

var context = {
PageTitle: 'nJSt demonstration',
List: ['One', 'Two', 'Three'],
ShowMessage: true
};

njst.render(data, context, {debug: true}, function (err, out) {
response.writeHead(200, {'content-type': 'text/html; charset=utf-8'});
response.end(out);
});
});
}).listen(8000);

## Author

Viacheslav Lotsmanov (unclechu)

## See also

https://github.com/visionmedia/ejs