Skip to content

Instantly share code, notes, and snippets.

@philleepflorence
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philleepflorence/bf51e31b6f6919dded6d to your computer and use it in GitHub Desktop.
Save philleepflorence/bf51e31b6f6919dded6d to your computer and use it in GitHub Desktop.
Handlebars helper for getting the first non empty variable or object property.
/* Usage: {{ONE name title description}} */
/* Similar to JavaScript: return name || title || description; */
Handlebars.registerHelper('ONE', function ()
{
var args = arguments;
for(var i in args) if(args[i] !== null && args[i] !== undefined) return args[i];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment