Last active
January 6, 2017 19:54
-
-
Save Zodiase/a088cb76ac93c6116f058aa9acd7e81c to your computer and use it in GitHub Desktop.
Blaze Useful Template Helpers
This file contains 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
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)); |
This file contains 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
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)); |
This file contains 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
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