Created
November 3, 2013 02:19
-
-
Save adamwdraper/7285783 to your computer and use it in GitHub Desktop.
Require.js Plugin to load uncompiled Handlebars templates
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
/** | |
* @appular hbs v0.0.1 - include file as text and convert it to a handlebars template | |
* @define hbs! | |
*/ | |
// hbtemplate.js plugin for requirejs / text.js | |
// it loads and compiles Handlebars templates | |
define([ | |
'handlebars' | |
], function (Handlebars) { | |
return { | |
load: function (name, req, onload, config) { | |
req([ | |
'text!' + name | |
], function (template) { | |
if (config.isBuild) { | |
//Indicate that the optimizer should not wait | |
//for this resource any more and complete optimization. | |
//This resource will be resolved dynamically during | |
//run time in the web browser. | |
onload(); | |
} else { | |
onload(Handlebars.compile(template)); | |
} | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment