Skip to content

Instantly share code, notes, and snippets.

@phobia
Created February 20, 2014 10:08
Show Gist options
  • Save phobia/9110443 to your computer and use it in GitHub Desktop.
Save phobia/9110443 to your computer and use it in GitHub Desktop.
Handlebars helper for outputing a partial without handlebars parsing its contents. Useful for outputing templates to be used client side.
(function() {
module.exports.register = function(Handlebars, options) {
/**
* Raw
* Output a partial as raw text
*
* Usage example:
* {{raw "my-partial"}}
*
* To avoid escaping of html etc., use triple curly braces:
* {{{raw "my-partial"}}}
*
* @param {string} partialName Name of a registered partial.
* @return {string}
*/
Handlebars.registerHelper('raw', function(partialName) {
return Handlebars.partials[partialName];
});
};
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment