mirror of
https://github.com/pantor/inja.git
synced 2026-02-17 09:03:58 +00:00
slight changes
This commit is contained in:
@@ -130,7 +130,7 @@ data["time"]["end"] = 22;
|
||||
render("{{ guests.1 }}", data); // "Tom"
|
||||
|
||||
// Objects
|
||||
render("{{ time.start }} to {{ time.end }}pm", data); // "16 to 22pm"
|
||||
render("{{ time.start }} to {{ time.end + 1 }}pm", data); // "16 to 23pm"
|
||||
```
|
||||
In general, the variables can be fetched using the [JSON Pointer](https://tools.ietf.org/html/rfc6901) syntax. For convenience, the leading `/` can be omitted. If no variable is found, valid JSON is printed directly, otherwise an error is thrown.
|
||||
|
||||
@@ -166,7 +166,7 @@ render("{% if time.hour >= 20 %}…{% else if time.hour >= 18 %}…{% endif %}",
|
||||
render("{% if neighbour in guests %}…{% endif %}", data); // True
|
||||
|
||||
// Logical operations
|
||||
render("{% if guest_count < 5 and all_tired %}…{% else %}…{% endif %}", data); // True
|
||||
render("{% if guest_count < (3+2) and all_tired %}…{% else %}…{% endif %}", data); // True
|
||||
|
||||
// Negations
|
||||
render("{% if not guest_count %}…{% endif %}", data); // True
|
||||
|
||||
@@ -262,4 +262,5 @@ TEST_CASE("combinations") {
|
||||
CHECK(env.render("{{ length(name) * 2.5 }}", data) == "12.5");
|
||||
CHECK(env.render("{{ upper(first(sort(brother.daughters)) + \"_test\") }}", data) == "HELEN_TEST");
|
||||
CHECK(env.render("{% for i in range(3) %}{{ at(names, i) }}{% endfor %}", data) == "JeffSebChris");
|
||||
CHECK(env.render("{% if not is_happy or age > 26 %}TRUE{% endif %}", data) == "TRUE");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user