Skip to content

Instantly share code, notes, and snippets.

@richard-flosi
Created March 17, 2014 17:15
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 richard-flosi/9603834 to your computer and use it in GitHub Desktop.
Save richard-flosi/9603834 to your computer and use it in GitHub Desktop.
.html extension compiler for nunjucks templates in hem for spine.
# add hem and nunjucks to your package.json
{
...
"dependencies": {
...
"hem": "~0.3.6",
"nunjucks": "~1.0.1"
}
}
var argv = process.argv.slice(2);
var path = require('path');
var hem = new (require('hem'))();
hem.compilers.html = function(path) {
var nunjucks = require('nunjucks'),
opts = {
asFunction: true
},
template = nunjucks.precompile(path, opts);
return "module.exports = " + template;
};
hem.exec(argv[0]);
# add nunjucks-slim.js to your libs
{
...
"packages": {
"appName": {
"libs": [
"lib/runtime.js",
"node_modules/nunjucks/browser/nunjucks-slim.js"
],
...
}
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment