Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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)
- Host: GitHub
- URL: https://github.com/unclechu/node-njst
- Owner: unclechu
- License: gpl-3.0
- Created: 2011-06-02T12:49:48.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-03-07T14:51:24.000Z (over 10 years ago)
- Last Synced: 2024-09-19T05:50:04.748Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 401 KB
- Stars: 13
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# nJSt (Native JavaScript Templates)
## Installing
npm install njst
## Usage
### HTML page.html
#{PageTitle}
#{PageTitle}
- #{item}
<# List.forEach(function (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