Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VeliovGroup/Meteor-Template-helpers
Template helpers for Session, logical operations and debug
https://github.com/VeliovGroup/Meteor-Template-helpers
helpers javascript meteor meteor-package meteorjs template templating
Last synced: about 2 months ago
JSON representation
Template helpers for Session, logical operations and debug
- Host: GitHub
- URL: https://github.com/VeliovGroup/Meteor-Template-helpers
- Owner: veliovgroup
- License: bsd-3-clause
- Created: 2015-01-30T15:59:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-05-31T14:19:16.000Z (over 2 years ago)
- Last Synced: 2024-11-15T00:12:07.035Z (about 2 months ago)
- Topics: helpers, javascript, meteor, meteor-package, meteorjs, template, templating
- Language: JavaScript
- Homepage: https://atmospherejs.com/ostrio/templatehelpers
- Size: 65.4 KB
- Stars: 35
- Watchers: 7
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-meteor - ostrio:templatehelpers - Utility helpers for your Blaze templates. (Packages)
- awesome-meteor - ostrio:templatehelpers - Utility helpers for your Blaze templates. (Forms and Templates)
README
[![support](https://img.shields.io/badge/support-GitHub-white)](https://github.com/sponsors/dr-dimitru)
[![support](https://img.shields.io/badge/support-PayPal-white)](https://paypal.me/veliovgroup)
# Meteor Template helpers
__Features:__
- 👨🔬 __100% tests coverage__;
- 💡 Lightweight - No external dependencies, all feature helpers has __only__ *weak* dependencies;
- ⚖️ Compare values with conditions - `{{#if compare one '===' two}} ... {{/if}}`;
- 🐒 Get/set Session (*weak dependency*) - `{{Session 'key' set='value'}}`, `{{#if Session 'key'}} ... {{/if}}`;
- 🔨 Use underscore's functions (*weak dependency*) - `{{#if _ 'isString' 'one'}} ... {{/if}}`;
- 👨💻 Debug/log passed objects as a string to template - `{{log this.someVal 'string' object="value"}}`.## Install:
```shell
meteor add ostrio:templatehelpers
```## Helpers
Use comparison, conditional, and logical operations right in the Blaze templates. Get access to `Session` object ans stored values. Execute `underscore` package methods. And debug Blaze templating data using `log` helper.
### `Session`
Get or set session value from views via Session helper
```handlebars
{{Session 'key'}}
{{Session 'key' set="new value"}}
{{Session 'key' set="new value" action="setDefault"}}
```### `log`
Template debugging - Log arguments into browser's console with output into template
```handlebars
{{log 'val' opt='val2' opt2=variable}}
```### Underscore (all methods)
Execute underscore methods in template
```handlebars
{{#if _ 'isString' 'one'}}
...
{{/if}}
```### Comparison helpers
Compare template data. Create conditional `if` and `unless` blocks.
#### Compare two values in template
```handlebars
{{#if compare 'one' '>' 'two'}}
{{/if}}
{{compare 'one' 'gt' 'two'}}
{{compare 'one' 'greaterThan' 'two'}}{{compare 'one' '>=' 'two'}}
{{compare 'one' 'gte' 'two'}}
{{compare 'one' 'greaterThanEqual' 'two'}}{{compare 'one' '<' 'two'}}
{{compare 'one' 'lt' 'two'}}
{{compare 'one' 'lessThan' 'two'}}{{compare 'one' '<=' 'two'}}
{{compare 'one' 'lte' 'two'}}
{{compare 'one' 'lessThanEqual' 'two'}}{{compare 'one' '===' 'two'}}
{{compare 'one' 'is' 'two'}}{{compare 'one' '!==' 'two'}}
{{compare 'one' 'isnt' 'two'}}{{compare 'one' '==' 'two'}}
{{compare 'one' 'isEqual' 'two'}}{{compare 'one' '!=' 'two'}}
{{compare 'one' 'isNotEqual' 'two'}}{{compare 'one' '&&' 'two'}}
{{compare 'one' 'and' 'two'}}{{compare 'one' '&!' 'two'}}
{{compare 'one' '!&' 'two'}}
{{compare 'one' '!&!' 'two'}}
{{compare 'one' '!&&' 'two'}}
{{compare 'one' 'nand' 'two'}}{{compare 'one' '||' 'two'}}
{{compare 'one' 'or' 'two'}}{{compare 'one' '|!' 'two'}}
{{compare 'one' '!|' 'two'}}
{{compare 'one' '!|!' 'two'}}
{{compare 'one' '!||' 'two'}}
{{compare 'one' 'nor' 'two'}}{{compare 'one' 'xor' 'two'}}
{{compare 'one' 'nxor' 'two'}}
```#### Compare many to many
Compare complex template data.
```handlebars
{{#if compare 1 '>' 2 '&&' 5 '<' 8}}
{{/if}}
{{compare 1 '>' 2 '||' 5 '<' 8}}
{{compare first '||' second '||' third}}
{{compare first '&&' second '&&' third}}
{{compare first '&&' second '||' third}}```
#### Compare one value to many (any of.. match)
Compare single value against many (*any of.. match*).
```handlebars
{{#if compare 'one' '>' 'two|one|three|four|five'}}
{{/if}}
{{compare 'one' '>=' 'two|one|three|four|five'}}
{{compare 'one' '<' 'two|one|three|four'}}
{{compare 'one' '<=' 'two|one|three'}}
{{compare 'one' '===' 'two|one'}}
{{compare 'one' '!==' 'two|one|three'}}
{{compare 'one' '==' 'two|one|three|four'}}
{{compare 'one' '!=' 'two|one|three|four'}}
{{compare 'one' '&&' 'two|one|three|four'}}
```## Running Tests
1. Clone this package
2. In Terminal (*Console*) go to directory where package is cloned
3. Then run:### Meteor/Tinytest
```shell
# Default
meteor test-packages ./# With custom port
meteor test-packages ./ --port 8888
```### Support our open source contribution
- [Sponsor via GitHub](https://github.com/sponsors/dr-dimitru)
- [Support via PayPal](https://paypal.me/veliovgroup)
- Use [ostr.io](https://ostr.io) — [Monitoring](https://snmp-monitoring.com), [Analytics](https://ostr.io/info/web-analytics), [WebSec](https://domain-protection.info), [Web-CRON](https://web-cron.info) and [Pre-rendering](https://prerendering.com) for a website