Created
March 13, 2014 22:51
-
-
Save richard-flosi/9538838 to your computer and use it in GitHub Desktop.
Use ect.js templates with hem by adding this to your slug.js for your spine.js project.
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
var argv = process.argv.slice(2); | |
var fs = require('fs'); | |
var path = require('path'); | |
var hem = new (require('hem'))(); | |
var ect = require('ect'); | |
// ect compiler | |
hem.compilers.ect = function(path) { | |
var renderer, content, template; | |
renderer = ect({}); | |
content = fs.readFileSync(path, 'utf8'); | |
template = renderer.compile(content); | |
return "module.exports = (function(data){ return (function(){ return " + template.toString() + " }).call(data); })"; | |
}; | |
hem.exec(argv[0]); |
NOTE: this only worked for a really simple case and in general is not working for me at the moment.
Some relavent links:
baryshev/ect#17
https://github.com/eliseumds/ect
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll need to add the following to your package.json:
and run