]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Support list literals for templates
authorKevin <github@kevin-brown.com>
Tue, 21 May 2024 18:45:22 +0000 (14:45 -0400)
committerKevin <github@kevin-brown.com>
Tue, 21 May 2024 18:45:22 +0000 (14:45 -0400)
Because lists can be dynamic this needs to be handled in the grammar
instead of in the lexer.

grammar/JinjaGrammar.g4

index eff36cd18a3b483976a9938b4f311aff713a6df6..c0743b3ac827ebddf892a4eacee70f78cc253ac1 100644 (file)
@@ -12,8 +12,19 @@ expression
 
 expressions     : expression*;
 
+list_literal            : LSQB SP? list_literal_values? SP? RSQB;
+list_literal_values
+    :
+    (list_literal_value SP? COMMA SP?)*
+    list_literal_value
+    ;
+list_literal_value
+    : STRING_LITERAL
+    ;
+
 statement_include_template_list
     : STRING_LITERAL
+    | list_literal
     ;
 
 statement_include_context