Skip to content

Instantly share code, notes, and snippets.

@richard-flosi
Created March 13, 2014 22:51
Show Gist options
  • Save richard-flosi/9538838 to your computer and use it in GitHub Desktop.
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.
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]);
@richard-flosi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment