Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@grejdi /compile.js
Last active

Using Rhino to compile Mustache templates with Hogan
// load 'hogan' library
// 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

To run :

java -jar rhino.jar compile.js templates.js

'compile.js' refers to this gist.
'templates.js' is the file to output to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.