Skip to content

Commit

Permalink
Merge pull request #6570 from mkouba/qute-if-operators
Browse files Browse the repository at this point in the history
Qute "if" section - support multiple conditions
  • Loading branch information
machi1990 authored Jan 17, 2020
2 parents 6e0e133 + ddac355 commit 373ce14
Show file tree
Hide file tree
Showing 9 changed files with 663 additions and 201 deletions.
54 changes: 46 additions & 8 deletions docs/src/main/asciidoc/qute-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -277,38 +277,76 @@ The simplest possible version accepts a single parameter and renders the content
You can also use the following operators:

|===
|Operator |Aliases
|Operator |Aliases |Precedence (higher wins)

|equals
|`eq`, `==`, `is`

|not equals
|`ne`, `!=`
|logical complement
|`!`
| 4

|greater than
|`gt`, `>`
| 3

|greater than or equal to
|`ge`, `>=`
| 3

|less than
|`lt`, `<`
| 3

|less than or equal to
|`le`, `\<=`
| 3

|equals
|`eq`, `==`, `is`
| 2

|not equals
|`ne`, `!=`
| 2

|logical AND (short-circuiting)
|`&&`, `and`
| 1

|logical OR (short-circuiting)
|`\|\|`, `or`
| 1

|===

.A simple operator example
[source]
----
{#if item.age > 10}
This item is very old.
{/if}
----

NOTE: Multiple conditions are not supported.
Multiple conditions are also supported.

.Multiple conditions example
[source]
----
{#if item.age > 10 && item.price > 500}
This item is very old and expensive.
{/if}
----

Precedence rules can be overridden by parentheses.

.Parentheses example
[source]
----
{#if (item.age > 10 || item.price > 500) && user.loggedIn}
User must be logged in and item age must be > 10 or price must be > 500.
{/if}
----


You can add any number of "else" blocks:
You can add any number of `else` blocks:

[source]
----
Expand Down
Loading

0 comments on commit 373ce14

Please sign in to comment.