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 a default operator #38

Closed
criocere opened this issue May 18, 2020 · 4 comments
Closed

Add a default operator #38

criocere opened this issue May 18, 2020 · 4 comments

Comments

@criocere
Copy link

Will it possible to add a default operator as

{{ myStringVar | "default" }} => if myString is null or empty, the output value is "default"
{{ myIntegerVar | 123 }} => if myInteger is null, the output value is "123"

Thx

@codeka
Copy link
Owner

codeka commented May 20, 2020

We have a ternary operator, so you could do something like this:

{{ myStringVar ? myStringVar : "default" }}

Though maybe a short-hand elvis operator would be nice:

{{ myStringVar ?: "default" }}

Would be nice to reduce the redundancy.

@criocere
Copy link
Author

Yes {{ myStringVar ?: "default" }} is a nice idea !

@codeka codeka closed this as completed in 5143f3a May 22, 2020
@codeka
Copy link
Owner

codeka commented May 22, 2020

{{ myStringVar ?: "default" }} should work from version 2.4.5.

@criocere
Copy link
Author

Great, thx!

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

No branches or pull requests

2 participants