Socket
Socket
Sign inDemoInstall

njst

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    njst

Native JavaScript Templates


Version published
Maintainers
1
Install size
17.0 kB
Created

Changelog

Source

0.2.1

  • Changed to async-style without backward compatibility (sorry for that guys)

Readme

Source

nJSt (Native JavaScript Templates) v0.2.1

Installing

npm install njst

Usage

HTML page.html

<html>
<head>
	<title>#{PageTitle}</title>
</head>

<body>
	<h1>#{PageTitle}</h1>

	<ul>
	<# List.forEach(function (item) { #>
		<li>#{item}</li>
	<# }) #>
	</ul>
	
	<# if (ShowMessage) { #>
		<p>nJSt loves you!</p>
	<# } #>
</body>
</html>

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)

FAQs

Last updated on 13 Nov 2012

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc