]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Add support for optional ":" at end of line statement
authorKevin Brown <kevin@kevin-brown.com>
Fri, 8 May 2020 23:18:38 +0000 (19:18 -0400)
committerKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 01:50:06 +0000 (21:50 -0400)
This does not fully work for the example file because the grammar
for a test expression can span multiple lines which causes the HTML
in the line following the block expression to be detected as a test
expression instead of being detected as content.

tatsu_grammar.txt

index ba9122d4f5c2afb1f6939ed935a48f55c753fe54..3aa9e05ac2da6795cf1845b22a95b5214e83e9a1 100644 (file)
@@ -70,7 +70,7 @@ line_block_expression
 \r
 line_block_start\r
     =\r
-    line_block_open type:`blockstart` !("end") name:IDENTIFIER {SP}* parameters:[ block_parameters ] { !"\n" SP }* ":\n"\r
+    line_block_open type:`blockstart` !("end") name:IDENTIFIER {SP}* parameters:[ line_block_parameters ] { !"\n" SP }* [ ":" { !"\n" SP }* ] "\n"\r
     ;\r
 \r
 line_block_end\r
@@ -83,6 +83,11 @@ line_block_open
     "\n" {SP}* @:"# " {SP}*\r
     ;\r
 \r
+line_block_parameters\r
+    =\r
+    @+:block_parameter { { !"\n" SP }* @+:block_parameter }*\r
+    ;\r
+\r
 implicit_identifier_tuple\r
     =\r
     tuple+:IDENTIFIER { {SP}* "," {SP}* tuple+:IDENTIFIER }+\r