Created
February 10, 2013 04:08
-
-
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.
This file contains 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
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