Created
April 9, 2014 17:59
-
-
Save richard-flosi/10297549 to your computer and use it in GitHub Desktop.
Hem precompiler for nunjucks templates
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
/* jshint node: true */ | |
var argv = process.argv.slice(2); | |
var fs = require('fs'); | |
var hem = new (require('hem'))(); | |
hem.compilers.html = function(path) { | |
var nunjucks = require('nunjucks'), | |
name = path.split('app/')[1], | |
opts = { | |
name: name, | |
asFunction: true | |
}, | |
content = fs.readFileSync(path, 'utf8'), | |
template = nunjucks.precompileString(content, opts); | |
return 'module.exports = ' + template; | |
}; | |
hem.exec(argv[0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment