]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Add function calls for variables
authorKevin Brown <kevin@kevin-brown.com>
Fri, 8 May 2020 10:44:18 +0000 (06:44 -0400)
committerKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 01:50:06 +0000 (21:50 -0400)
This allows for functions to be called, currently with a single
variable optionally passed.

This also adds a check to make sure that variable literals are
supported.

tatsu_grammar.txt
test_template.jinja

index 3cc2e7c58c534d0146781504fb97ee0f60adc2fe..a17dc3b1fd2a8a713f44d0c5e5495b459cb8a3b3 100644 (file)
@@ -87,7 +87,7 @@ variable_identifier
 \r
 variable_accessor\r
     =\r
-    variable_accessor_brackets | variable_accessor_dot\r
+    variable_accessor_brackets | variable_accessor_call | variable_accessor_dot\r
     ;\r
 \r
 variable_accessor_brackets\r
@@ -95,6 +95,11 @@ variable_accessor_brackets
     "[" variable_identifier "]"\r
     ;\r
 \r
+variable_accessor_call\r
+    =\r
+    "(" [variable_identifier] ")"\r
+    ;\r
+\r
 variable_accessor_dot\r
     =\r
     "." variable_identifier\r
index 7d747cdc8c9b31ad24155afb1e57b67572c1c28c..8847e41b3a79dc7c04a3778829533598cbde1fed 100644 (file)
@@ -3,8 +3,12 @@
 {%block single key=val param=value %}\r
 test {{var}}\r
 {%endblock%}\r
+{% for item in dict_var.values() %}\r
+    <li>{% block loop_item %}{{ item }}{% endblock %}</li>\r
+{% endfor %}\r
 {# comment contents\r
 across lines #}\r
 {% raw %}\r
     {% block %}fake content{{ fake vars }}\r
-{% endraw %}
\ No newline at end of file
+{% endraw %}\r
+{{ '{{' }}
\ No newline at end of file