Last active
August 29, 2015 13:57
-
-
Save rossipedia/9795859 to your computer and use it in GitHub Desktop.
Hogan example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello there. My name is John Doe. I am 24 years old. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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