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

Qute IfSectionHelper - consider truthy values during evaluation #8582

Closed
mkouba opened this issue Apr 15, 2020 · 4 comments · Fixed by #8602
Closed

Qute IfSectionHelper - consider truthy values during evaluation #8582

mkouba opened this issue Apr 15, 2020 · 4 comments · Fixed by #8602
Assignees
Labels
area/qute The template engine kind/enhancement New feature or request
Milestone

Comments

@mkouba
Copy link
Contributor

mkouba commented Apr 15, 2020

Currently, the param must be evaluated to true. We could consider a truthy value instead. I.e. something like https://developer.mozilla.org/en-US/docs/Glossary/Truthy.

Also consider adding the unless tag that would render the content if the param evaluates to a falsy value. We can use logical complement, e.g. {#if !collection}.

Examples:

{#if string}
  Renders if non-empty string
{/if}
{#if collection}
    Renders if non-empty collection
{/if}
{#if number}
  Renders if number not 0
{/if}
@mkouba mkouba added kind/enhancement New feature or request area/qute The template engine labels Apr 15, 2020
@quarkusio quarkusio deleted a comment from quarkusbot Apr 15, 2020
@Ladicek
Copy link
Contributor

Ladicek commented Apr 15, 2020

Instead of JavaScript rules, I'd suggest using Groovy rules: http://groovy-lang.org/semantics.html#Groovy-Truth (which are actually pretty close to what you describe).

@mkouba
Copy link
Contributor Author

mkouba commented Apr 15, 2020

@Ladicek +1

I was thinking of using this https://github.com/trimou/trimou/blob/master/core/src/main/java/org/trimou/util/Checker.java#L84-L101 which is essentially the same (except for the matchers).

@mkouba mkouba self-assigned this Apr 15, 2020
@gsmet
Copy link
Member

gsmet commented Apr 15, 2020

If we want to do that, let's do it dirty and use the PHP or Javascript rules :).

That will be far more interesting and a constant stream of easy bugs to fix :).

@mkouba
Copy link
Contributor Author

mkouba commented Apr 15, 2020

We're not talking about a proper type coercion ;-). Those rules are IMO fine (if documented).

mkouba added a commit to mkouba/quarkus that referenced this issue Apr 15, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Apr 15, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Apr 15, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Apr 16, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Apr 16, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Apr 16, 2020
mkouba added a commit to mkouba/quarkus that referenced this issue Apr 16, 2020
@gsmet gsmet added this to the 1.4.0.Final milestone Apr 20, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants