Skip to content

Instantly share code, notes, and snippets.

@rossipedia
Last active August 29, 2015 13:57
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 rossipedia/9795859 to your computer and use it in GitHub Desktop.
Save rossipedia/9795859 to your computer and use it in GitHub Desktop.
Hogan example
// This is an async example
var fs = require('fs');
var path = require('path');
var hogan = require('hogan.js');
fs.readFile(path.resolve(__dirname, 'template.hogan'), 'utf8', function(err, template) {
if (err) {
console.error(err);
return;
}
var compiled = hogan.compile(template);
var data = {
name: "John Doe",
age: 24
};
console.log(compiled.render(data));
});
var fs = require('fs');
var path = require('path');
var hogan = require('hogan.js');
var template = fs.readFileSync(path.resolve(__dirname, 'template.hogan'), 'utf8');
var compiled = hogan.compile(template);
var data = {
name: "John Doe",
age: 24
};
console.log(compiled.render(data));
Hello there. My name is John Doe. I am 24 years old.
Hello there. My name is {{name}}. I am {{age}} years old.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment