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

Support boolean conditionals #10

Closed
anowell opened this issue Feb 7, 2017 · 2 comments
Closed

Support boolean conditionals #10

anowell opened this issue Feb 7, 2017 · 2 comments

Comments

@anowell
Copy link

anowell commented Feb 7, 2017

It'd be nice to be able to express at least basic boolean conditionals in templates.

{{#is_condition}}content{{/is_condition}

This actually works if if is_condition is an Option<()> (thanks to IntoIterator), but not if it is a bool.

@maghoff
Copy link
Owner

maghoff commented Feb 7, 2017

Yeah, I'm exploring a design for this. It is not documented, but it is actually possible already, by using a trailing ?, like so:

{{#is_condition?}}content{{/is_condition}}

Limiting it to bool seems weird, so I have introduced a Conditional trait in between there, which you can make use of to have other types as the condition.

You might want to look at the relevant tests.

Thanks for your feedback, keep it coming :) I am going to close this now, but feel free to give feedback about how you feel this is working and where you might find it lacking.

@maghoff maghoff closed this as completed Feb 7, 2017
@anowell
Copy link
Author

anowell commented Feb 7, 2017

Perfect. Thanks.

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