From 3cf36bbefa1c659861ef3376f3c4d97f1c9db844 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 2 Nov 2020 18:44:55 +0100 Subject: 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 --- lexer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lexer.c') diff --git a/lexer.c b/lexer.c index eb513b8..f14a944 100644 --- a/lexer.c +++ b/lexer.c @@ -142,6 +142,7 @@ static const struct token reserved_words[] = { { T_CATCH, "catch", 5 }, { T_BOOL, "false", 5, { .b = false } }, { T_BOOL, "true", 4, { .b = true } }, + { T_ELIF, "elif", 4 }, { T_ELSE, "else", 4 }, { T_THIS, "this", 4 }, { T_NULL, "null", 4 }, -- cgit v1.2.3