Skip to content
Myr

[svn] added missing documentation file

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 2158091 · Browse files · 1 file+81 added−0 removed
This commit

State

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

1 file+81 added−0 removed

added:docs/src/altsyntax.txt+81 added
1==================2Alternative Syntax3==================45Jinja allows some syntax customization for the block delimiters. Depending on6the Jinja release more or less combinations are possible. The idea of an7customizable syntax is that you can update existing templates from other8template engines and programming languages easier and that you can replace9the django like default delimiters which are not everybody's favorite.101112Configuring The Environment13===========================1415For syntax configuration there are six arguments in the environment which16are the first six for convenience. Thus those two snippets do the same:1718.. sourcecode:: python1920 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 )2829 env = Environment('{%', '%}', '{{', '}}', '{#', '#]')303132Ruby Like Syntax33----------------3435Here an example configuration for Ruby-like syntax:3637.. sourcecode:: python3839 env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>')4041An example template then looks like this:4243.. sourcecode:: rhtml4445 <%# example eruby like configuration for jinja %>46 <ul>47 <% for item in seq %>48 <li><%= item %></li>49 <% endfor %>50 </ul>515253SGML Comment Syntax54-------------------5556Here an example configuration that uses SGML comments to hide the57processing instructions. This can be useful if you work with an WYSIWYG58designer:5960.. sourcecode:: python6162 env = Environment('<!--', '-->', '${', '}', '<!--#', '-->')6364.. sourcecode:: html6566 <!--# example eruby like configuration for jinja -->67 <ul>68 <!-- for item in seq -->69 <li>${item}</li>70 <!-- endfor -->71 </ul>727374Parenthesis Balancing75---------------------7677Starting with Jinja 1.1 it's possible to use the block delimiter as a token78in the expression. That means that you can use small delimiters like single79braces 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 need81Jinja 1.1 or higher.