Skip to content

Instantly share code, notes, and snippets.

@tissak
Created December 28, 2011 03:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tissak/1526087 to your computer and use it in GitHub Desktop.
Save tissak/1526087 to your computer and use it in GitHub Desktop.
Haml support in Spine without hacking spine

Spine & Haml

  • Mod the package.json file to include haml-coffe
  • run the "npm install ." command to install the lib
  • Modify the slug.json to include haml-coffee to provide the lib
  • Add the slug.js to the root folder of the app to load up haml support

running hem server should now support finding .haml files in the view folder

{
"name": "app",
"version": "0.0.1",
"dependencies": {
"serveup": "~0.0.2",
"hem": "~0.1.6",
"es5-shimify": "~0.0.1",
"json2ify": "~0.0.1",
"jqueryify": "~0.0.1",
"spine": "~1.0.5",
"haml-coffee": "~0.5.5"
}
}
var hem = new (require('hem'));
var HamlCoffee = require('haml-coffee/lib/haml-coffee');
var CoffeeScript = require('coffee-script')
var fs = require('fs');
var argv = process.argv.slice(2);
hem.compilers.haml = function(path) {
var compiler = new HamlCoffee({})
var content = fs.readFileSync(path, 'utf8')
compiler.parse(content)
template = CoffeeScript.compile(compiler.render("template", "context"))
return "module.exports = (function(data){ "+template+" return context['template'](data); })"
};
hem.exec(argv[0]);
{
"dependencies": [
"es5-shimify",
"json2ify",
"jqueryify",
"spine",
"spine/lib/local",
"spine/lib/ajax",
"spine/lib/route",
"spine/lib/tmpl",
"spine/lib/manager",
"haml-coffee/lib/haml-coffee"
],
"libs": []
}
@jupp0r
Copy link

jupp0r commented Mar 11, 2012

Nice, thank you!

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