Skip to content

Instantly share code, notes, and snippets.

@carltondickson
Last active August 29, 2015 14:19
Show Gist options
  • Save carltondickson/ddae15ce1bab5410695c to your computer and use it in GitHub Desktop.
Save carltondickson/ddae15ce1bab5410695c to your computer and use it in GitHub Desktop.
Handlebarjs debug helper
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value");
console.log("====================");
console.log(optionalValue);
}
});
/*
You could then use that helper in any template like:
{{debug}}
{{debug someValue}}
Current Context
====================
email: "alan@test.com"
first_name: "Alan"
last_name: "Johnson"
member_since: "Mar 25, 2011"
phone: "1234567890"
stripeClass: "even"
__proto__: Object
Value
====================
Alan
*/
// source http://blog.teamtreehouse.com/handlebars-js-part-3-tips-and-tricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment