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

Suggestion: valueIn helper #67

Open
Kerrick opened this issue Sep 17, 2013 · 5 comments
Open

Suggestion: valueIn helper #67

Kerrick opened this issue Sep 17, 2013 · 5 comments

Comments

@Kerrick
Copy link

Kerrick commented Sep 17, 2013

How about an inverse of the {{inArray}} helper? Something that would work like the example docs below.

If there's enough interest in this I'd be glad to submit a pull request and make it so. If I do so, which section should it go into? (Collections?)


{{valueIn}}

Conditionally render a block if the value is in a specified collection.
Parameters: value string|int - One or more values to test against. (Required), [...]

Data:

"value": "Fry"

Template:

{{#valueIn value "Professor Farnsworth" "Fry" "Bender"}}
  I'm walking on sunshine!
{{else}}
  I'm walking on darkness.
{{/valueIn}}

Renders to:

I'm walking on sunshine!
@jonschlinkert
Copy link
Member

Love it! How about ifExists instead? Would be great if you did a pr, I think it should go with the comparison helpers. Also, docs for the comparison helpers is here: https://github.com/assemble/assemble-docs/tree/master/src/content/helpers/comparison

However, the assemble-docs repo isn't as easy as it could (will) be to add documentation, so I would be happy to add the docs for if you want, or if you want to contribute to that repo feel free to add it yourself.
thanks!

@jonschlinkert
Copy link
Member

@Kerrick just wanted to offer some assistance, would love to see this merged in.

@jonschlinkert
Copy link
Member

@Kerrick ping, I can add this but wanted to check one more time to see if you want to do it

@Kerrick
Copy link
Author

Kerrick commented Oct 14, 2013

Oh sure, I'll push it up to GH this evening. :-)

@jonschlinkert
Copy link
Member

👍 awesome thx

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

No branches or pull requests

2 participants