]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Start definining variable identifiers
authorKevin Brown <kevin@kevin-brown.com>
Fri, 8 May 2020 10:21:58 +0000 (06:21 -0400)
committerKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 01:50:06 +0000 (21:50 -0400)
Variables are standard identifiers or literals that can be
augmented by accessors (either dictionary or dot style). This
finally defines what a string is.

tatsu_grammar.txt
test_template.jinja

index 14ece8984289b6925953efc4cd606fb7e2fb8cbe..1138236ffefe48ab58ed2d3aeee3d194d9d3a874 100644 (file)
@@ -68,7 +68,7 @@ block_parameter_value
 \r
 variable_expression\r
     =\r
-    variable_open IDENTIFIER { !variable_close variable_filter }* variable_close\r
+    variable_open variable_identifier { !variable_close variable_filter }* variable_close\r
     ;\r
 variable_open\r
     =\r
@@ -79,6 +79,17 @@ variable_close
     {SP}* @:"}}"\r
     ;\r
 \r
+variable_identifier\r
+    =\r
+    ( IDENTIFIER | STRING )\r
+    { variable_accessor }*\r
+    ;\r
+\r
+variable_accessor\r
+    =\r
+    "[" variable_identifier "]"\r
+    ;\r
+\r
 variable_filter\r
     =\r
     {SP}* "|" {SP}* @:filter\r
@@ -112,9 +123,24 @@ comment_content         = {!comment_close CHAR}* ;
 \r
 content                 = !(block_open | variable_open | comment_open) CHAR ;\r
 \r
+STRING\r
+    =\r
+    SINGLE_QUOTE_STRING | DOUBLE_QUOTE_STRING\r
+    ;\r
+\r
+SINGLE_QUOTE_STRING\r
+    =\r
+    "'" { !"'" ?'.' }* "'"\r
+    ;\r
+\r
+DOUBLE_QUOTE_STRING\r
+    =\r
+    '"' { !'"' ?'.' }* '"'\r
+    ;\r
+\r
 IDENTIFIER\r
     =\r
-    /[a-zA-Z][a-zA-Z0-9]*/\r
+    /[a-zA-Z_][a-zA-Z0-9_]*/\r
     ;\r
 \r
 ALPHA\r
index 0240e9559ad41cce8f0e06bae864b805124a9e65..804c1b280c479ce56c46249586802b9011a62433 100644 (file)
@@ -1,5 +1,5 @@
 {% with key=val %}\r
-{{ kkk  |test(first ,second, third)|filter | lastFilter}}\r
+{{ dict_var['single']["double"]  |test(first ,second, third)|filter | lastFilter}}\r
 {%block single key=val param=value %}\r
 test {{var}}\r
 {%endblock%}\r