diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-11-02 18:44:55 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-11-02 19:43:13 +0100 |
commit | 3cf36bbefa1c659861ef3376f3c4d97f1c9db844 (patch) | |
tree | 99c9e9d4eadf2a58aa1073532d22d57481c2c04a /eval.c | |
parent | f23fb27f949f28517bef5206a5773f08d8202ea8 (diff) |
syntax: support `elif` clauses for alternative `if` syntax
In the alternative `if` syntax mode, support a specific `elif` keyword instead
of requiring an `else` branch followed by a disjunct `if` statement.
The advantage is that templates do not require error-prone redundant `endif`
keywords in else-if ladders.
After this change, the following example:
{% if (...): %}
One condition
{% else if (...): %}
Another condition
{% else if (...): %}
A third condition
{% else %}
Final condition
{% endif; endif; endif %}
... can be simplified into:
{% if (...): %}
One condition
{% elif (...): %}
Another condition
{% elif (...): %}
A third condition
{% else %}
Final condition
{% endif %}
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1562,6 +1562,7 @@ static struct json_object *(*fns[__T_MAX])(struct ut_state *, uint32_t) = { [T_LBRACK] = ut_execute_lbrack, [T_LBRACE] = ut_execute_object, [T_IF] = ut_execute_if, + [T_ELIF] = ut_execute_if, [T_QMARK] = ut_execute_if, [T_FOR] = ut_execute_for, [T_WHILE] = ut_execute_while, |