Skip to content

Instantly share code, notes, and snippets.

@adeubank

adeubank/inspectHelper.js

Last active Aug 29, 2015
Embed
What would you like to do?
Have handlebars output a JSON object of 'this' or passed in value. In my Googling, I didn't find anything on my first try, so I made this!
Handlebars.registerHelper('inspect', function(context) {
return JSON.stringify(context, null, 2) || JSON.stringify(this, null, 2);
});
// Usage: <pre>{{inspect}}</pre> or <pre>{{inspect variableName}}</pre> for nicely formatted code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment