Last active
October 10, 2015 16:38
-
-
Save grejdi/3719753 to your computer and use it in GitHub Desktop.
Using Rhino to compile Mustache templates with Hogan
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
// load 'hogan' library | |
load('js/lib/hogan/web/builds/2.0.0/hogan-2.0.0.js'); | |
// initialize templates object | |
print('var templates = {'); | |
// read mustache template content from file path | |
template = readFile('templates/index.mustache'); | |
// print compiled function from Hogan | |
print('"index" : new Hogan.Template(' + Hogan.compile(template, {asString : true}) + ')'); | |
// close object | |
print('};'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run :
'compile.js' refers to this gist.
'templates.js' is the file to output to.