Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boolean helpers #21

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add boolean helpers #21

wants to merge 6 commits into from

Conversation

vincent-psarga
Copy link
Contributor

@vincent-psarga vincent-psarga commented Oct 24, 2019

Basically, support simple boolean helpers to introduce a bit of logic in the templates.

  • eq to compare equality between items
  • includes to check if item2 is included in item 1
  • gt to check if item1 is greater than item1
  • gte to check if item1 is greater than or equal to item1
  • lt to check if item1 is lesser than item1
  • lte to check if item1 is lesser than or equal to item1

The idea is to use those helpers inside other helpers (if or unless).

Example:

{{#if (eq name "John")}}
  Hello Johnny!
{{else}}
  Hello {{name}} !
{{/if}}

@d316
Copy link
Contributor

d316 commented Oct 24, 2019

IMHO this diverges from the standard functionality of handlebars, i.e., this feature-set is not a part of the built-in handlebars helpers. Perhaps consider moving this into a plugin lib separate from this lib to keep this consistent with the standard feature-set of handlebars. Cf. https://github.com/jmurphyau/ember-truth-helpers for keeping truth helpers separate from the handlebars proper.

@vincent-psarga
Copy link
Contributor Author

vincent-psarga commented Oct 25, 2019

Thanks for the comment. In fact I'm using truth-helper on another project and I thought it was handlebars built-in.

I'll move that to another gem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants