Last active
August 29, 2015 14:12
-
-
Save adeubank/a8df5ba181ff3126e381 to your computer and use it in GitHub Desktop.
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!
This file contains hidden or 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
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