Skip to content

Instantly share code, notes, and snippets.

@garth
Created December 1, 2011 14:05
Show Gist options
  • Save garth/1416960 to your computer and use it in GitHub Desktop.
Save garth/1416960 to your computer and use it in GitHub Desktop.
Handlebars block helper for only outputting when a property is defined
// 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