Skip to content

Instantly share code, notes, and snippets.

@d-adamkiewicz
Created March 11, 2014 14:05
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 d-adamkiewicz/9486313 to your computer and use it in GitHub Desktop.
Save d-adamkiewicz/9486313 to your computer and use it in GitHub Desktop.
express3-handlebars "render" and "loadTemplate" example
var exphbs = require('express3-handlebars'),
hbs = exphbs.create();
var context = {data: 'Some girls wander by mistake'};
hbs.loadTemplate('test.hbs', function(err, compile) {
if (err) {
return console.error(err);
}
var compiled = compile(context);
console.log(compiled);
});
hbs.render('test.hbs', context, function(err, rendered) {
if (err) {
return console.error(err);
}
console.log(rendered);
})
Frankie says:
{{data}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment