Skip to content

Instantly share code, notes, and snippets.

@richard-flosi
Created March 13, 2014 22:51
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/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

You'll need to add the following to your package.json:

    "hem": "~0.3.6",
    "ect": "~0.5.6"

and run

npm install

@richard-flosi
Copy link
Author

NOTE: this only worked for a really simple case and in general is not working for me at the moment.

@richard-flosi
Copy link
Author

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