Skip to content

Instantly share code, notes, and snippets.

@gwendall
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save gwendall/83ca0263d5d9dd72d490 to your computer and use it in GitHub Desktop.

Select an option

Save gwendall/83ca0263d5d9dd72d490 to your computer and use it in GitHub Desktop.
Helper that brings Underscore directly in Meteor Templates
UI.registerHelper('_', function() {
arguments = _.toArray(arguments);
var self = this,
fn = arguments[0];
arguments.shift(); // Removes the Underscore function
arguments.pop(); // Remove the Spacebars appended argument
return _[fn].apply(self, arguments);
});
/*
Example:
{{#if _ "isString" "bonjour"}}
It is!
{{else}}
It is not :(
{{/if}}
Would return "It is!"
*/
@renews
Copy link
Copy Markdown

renews commented Aug 10, 2014

Nice one, thanks for sharing.

@elie222
Copy link
Copy Markdown

elie222 commented Aug 12, 2014

Nice. Didn't realise how simple this would be

@jimbog
Copy link
Copy Markdown

jimbog commented Nov 13, 2014

Mind blown! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment