Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

njst

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

njst

Native JavaScript Templates

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by9.09%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 13 Nov 2012

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc