mirror of
https://github.com/pantor/inja.git
synced 2026-04-04 15:18:53 +00:00
Improve conditions examples in readme
This commit is contained in:
10
README.md
10
README.md
@@ -158,17 +158,17 @@ In a loop, the special variables `loop/index (number)`, `loop/index1 (number)`,
|
||||
|
||||
Conditions support the typical if, else if and else statements. Following conditions are for example possible:
|
||||
```.cpp
|
||||
// Standard comparisons with variable
|
||||
render("{% if time.hour >= 20 %}…{% else if time.hour >= 18 %}…{% endif %}", data); // True
|
||||
// Standard comparisons with a variable
|
||||
render("{% if time.hour >= 20 %}Serve{% else if time.hour >= 18 %}Make{% endif %} dinner.", data); // Serve dinner.
|
||||
|
||||
// Variable in list
|
||||
render("{% if neighbour in guests %}…{% endif %}", data); // True
|
||||
render("{% if neighbour in guests %}Turn up the music!{% endif %}", data); // Turn up the music!
|
||||
|
||||
// Logical operations
|
||||
render("{% if guest_count < (3+2) and all_tired %}…{% else %}…{% endif %}", data); // True
|
||||
render("{% if guest_count < (3+2) and all_tired %}Sleepy...{% else %}Keep going...{% endif %}", data); // Sleepy...
|
||||
|
||||
// Negations
|
||||
render("{% if not guest_count %}…{% endif %}", data); // True
|
||||
render("{% if not guest_count %}The End{% endif %}", data); // The End
|
||||
```
|
||||
|
||||
#### Includes
|
||||
|
||||
Reference in New Issue
Block a user