From: Kevin Brown Date: Fri, 8 May 2020 22:09:09 +0000 (-0400) Subject: Add support for line statements X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b030045a7a2ec5517f59be29bf5736edfab2314e;p=thirdparty%2Fjinja.git Add support for line statements These are block expresions but the start/end tags take up an entire line and are marked by a leading symbol. --- diff --git a/tatsu_grammar.txt b/tatsu_grammar.txt index 1f5da0f8..73cce50d 100644 --- a/tatsu_grammar.txt +++ b/tatsu_grammar.txt @@ -11,7 +11,7 @@ expressions expression = - content | raw_block_expression | block_expression | variable_expression | comment_expression + content | raw_block_expression | block_expression | line_block_expression | variable_expression | comment_expression ; raw_block_expression @@ -56,6 +56,28 @@ block_close {SP}* @:"%}" ; +line_block_expression + = + line_block_start + expressions + line_block_end + ; + +line_block_start + = + line_block_open type:`blockstart` name:IDENTIFIER parameters:[ { block_parameter }* ] ":\n" + ; + +line_block_end + = + line_block_open type:`blockend` name:IDENTIFIER "\n" + ; + +line_block_open + = + "\n" @:"# " {SP}* + ; + implicit_identifier_tuple = {SP}* tuple+:IDENTIFIER {SP}* { "," {SP}* tuple+:IDENTIFIER {SP}* }+ @@ -200,7 +222,7 @@ comment_open = "{#" ; comment_close = "#}" ; comment_content = {!comment_close CHAR}* ; -content = !(block_open | variable_open | comment_open) CHAR ; +content = !(line_block_open | block_open | variable_open | comment_open) CHAR ; LITERAL = diff --git a/test_template.jinja b/test_template.jinja index d3b16cbc..57a6b6c8 100644 --- a/test_template.jinja +++ b/test_template.jinja @@ -34,4 +34,10 @@ across lines #} {% macro textarea(name, value='', rows=10, cols=40) %} -{% endmacro %} \ No newline at end of file +{% endmacro %} + \ No newline at end of file