Created
December 1, 2011 14:05
-
-
Save garth/1416960 to your computer and use it in GitHub Desktop.
Handlebars block helper for only outputting when a property is defined
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
// only output the block if the object property exists/is defined | |
// | |
// {{#defined property}} | |
// Property exists | |
// {{/defined}} | |
Handlebars.registerHelper('defined', function(property, block) { | |
return typeof(this[property]) !== 'undefined' ? block(this) : ''; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment