Improve conditions examples in readme

This commit is contained in:
pantor
2021-01-01 21:31:43 +01:00
committed by GitHub
parent 15b3e16bd5
commit 3cc82e934e

View File

@@ -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