Skip to content

Instantly share code, notes, and snippets.

@acthp
Created February 10, 2013 04:08
Show Gist options
  • Save acthp/4748312 to your computer and use it in GitHub Desktop.
Save acthp/4748312 to your computer and use it in GitHub Desktop.
Wrap requirejs text plugin so it will compile haml templates during development. Doesn't work during build.
define(['text', 'lib/haml'], function(text, haml) {
var plugin = Object.create(text); // inherit methods of the text loader
function wrapload(fn) {
return function(value) {
fn(haml.compileHaml({source: value}));
}
}
function load(name, req, onload, config) {
return text.load(name, req, wrapload(onload), config);
}
plugin.load = load;
return plugin;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment