Skip to content

Instantly share code, notes, and snippets.

@halfzebra
Created August 30, 2016 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halfzebra/307f29a52999a4cd85b81b7c8e476f48 to your computer and use it in GitHub Desktop.
Save halfzebra/307f29a52999a4cd85b81b7c8e476f48 to your computer and use it in GitHub Desktop.
Print HTML comment with template name
Handlebars.templates = new Proxy(Handlebars.templates, {
get: function (target, property) {
var TEMPLATE_KEY = '<!-- TEMPLATE: Teamplates/' + property + '.handlebars -->\n'
var method = target[ property ];
if (typeof target[ property ] === 'function') {
return new Proxy(method, {
apply: function (target, thisArg, argumentsList) {
return TEMPLATE_KEY + target.apply(thisArg, argumentsList) + TEMPLATE_KEY;
}
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment