Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+81 added−0 removed
other:+81 added−0 removed
Provenance
Commit
6d0b195
Tree
0a5941b
Author
Armin Ronacher <armin.ronacher@active-4.com>
Committer
Armin Ronacher <armin.ronacher@active-4.com>
Parent
2158091
1 file changed+81 added−0 removed
added:docs/src/altsyntax.txt+81 added
1+==================2+Alternative Syntax3+==================4+5+Jinja allows some syntax customization for the block delimiters. Depending on6+the Jinja release more or less combinations are possible. The idea of an7+customizable syntax is that you can update existing templates from other8+template engines and programming languages easier and that you can replace9+the django like default delimiters which are not everybody's favorite.10+11+12+Configuring The Environment13+===========================14+15+For syntax configuration there are six arguments in the environment which16+are the first six for convenience. Thus those two snippets do the same:17+18+.. sourcecode:: python19+20+ env = Environment(21+ block_start_string='{%',22+ block_end_string='%}',23+ variable_start_string='{{',24+ variable_end_string='}}',25+ comment_start_string='{#',26+ comment_end_string='#}',27+ )28+29+ env = Environment('{%', '%}', '{{', '}}', '{#', '#]')30+31+32+Ruby Like Syntax33+----------------34+35+Here an example configuration for Ruby-like syntax:36+37+.. sourcecode:: python38+39+ env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>')40+41+An example template then looks like this:42+43+.. sourcecode:: rhtml44+45+ <%# example eruby like configuration for jinja %>46+ <ul>47+ <% for item in seq %>48+ <li><%= item %></li>49+ <% endfor %>50+ </ul>51+52+53+SGML Comment Syntax54+-------------------55+56+Here an example configuration that uses SGML comments to hide the57+processing instructions. This can be useful if you work with an WYSIWYG58+designer:59+60+.. sourcecode:: python61+62+ env = Environment('<!--', '-->', '${', '}', '<!--#', '-->')63+64+.. sourcecode:: html65+66+ <!--# example eruby like configuration for jinja -->67+ <ul>68+ <!-- for item in seq -->69+ <li>${item}</li>70+ <!-- endfor -->71+ </ul>72+73+74+Parenthesis Balancing75+---------------------76+77+Starting with Jinja 1.1 it's possible to use the block delimiter as a token78+in the expression. That means that you can use small delimiters like single79+braces or parenthesis. So if you want to have your variables to look like80+``${expr}`` and you still want to use dicts in such expressions you need81+Jinja 1.1 or higher.