Created
March 17, 2014 17:15
-
-
Save richard-flosi/9603834 to your computer and use it in GitHub Desktop.
.html extension compiler for nunjucks templates in hem for spine.
This file contains 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
# add hem and nunjucks to your package.json | |
{ | |
... | |
"dependencies": { | |
... | |
"hem": "~0.3.6", | |
"nunjucks": "~1.0.1" | |
} | |
} |
This file contains 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 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]); |
This file contains 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
# 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