Skip to content

Instantly share code, notes, and snippets.

@indapublic
Created December 25, 2015 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indapublic/e4331f207fab836ca02c to your computer and use it in GitHub Desktop.
Save indapublic/e4331f207fab836ca02c to your computer and use it in GitHub Desktop.
Nsmarty example
var
util = require('util'),
http = require('http'),
nsmarty = require('nsmarty'),
Router = require('node-simple-router');
var router = new Router();
nsmarty.tpl_path = __dirname + '';
function output (name) {
console.log(name);
var stream = nsmarty.assign('template.tpl', {
name: name
});
return stream;
};
router.get('/', function (request, response) {
util.pump(output('index'), response);
});
router.get('/one', function (request, response) {
util.pump(output('one'), response);
});
router.get('/two', function (request, response) {
util.pump(output('two'), response);
});
router.get('/three', function (request, response) {
util.pump(output('three'), response);
});
var server = http.createServer(router);
server.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment