Skip to content

Instantly share code, notes, and snippets.

@Zodiase
Last active January 6, 2017 19:54
Show Gist options
  • Save Zodiase/a088cb76ac93c6116f058aa9acd7e81c to your computer and use it in GitHub Desktop.
Save Zodiase/a088cb76ac93c6116f058aa9acd7e81c to your computer and use it in GitHub Desktop.
Blaze Useful Template Helpers
import { Template } from 'meteor/templating';
/**
* Returns true when any of the provided arguments is true.
* Example:
* > {{#if some varA varB varC}}
* > At least something is true.
* > {{/if}}
*/
Template.registerHelper('some', (...args) => args.some(Boolean));
import { Template } from 'meteor/templating';
/**
* Returns true when all of the provided arguments are true.
* Example:
* > {{#if every varA varB varC}}
* > Everything is true.
* > {{/if}}
*/
Template.registerHelper('every', (...args) => args.every(Boolean));
import { Template } from 'meteor/templating';
Template.registerHelper('stringify', (item, options) => EJSON.stringify(item, options));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment