diff --git a/README.md b/README.md index e3f79e4..906f3c3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/test-functions.cpp b/test/test-functions.cpp index 2252c1a..b846446 100644 --- a/test/test-functions.cpp +++ b/test/test-functions.cpp @@ -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"); }