|
1548.
|
|
|
Syntax
|
|
|
|
Синтаксис
|
|
Translated by
Xavier (Open ERP)
|
|
|
|
|
0d494920c7fe42dbaad161bd923c892b
368cfbc4738046c79dce4260901447f7
|
|
Located in
../../source/developer/05_reports.rst:1012
../../source/developer/Web_client_v6/mako_template.rst:144
|
|
1549.
|
|
|
A Mako template is parsed from a text stream containing any kind of content, XML, HTML, email text, etc.
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1014
|
|
1550.
|
|
|
The template can further contain Mako-specific directives which represent variable and/or expression substitutions, control structures (i.e. conditionals and loops), server-side comments, full blocks of Python code, as well as various tags that offer additional functionality. All of these constructs compile into real Python code.
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1016
|
|
1551.
|
|
|
This means that you can leverage the full power of Python in almost every aspect of a Mako template.
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1018
|
|
1552.
|
|
|
Expression Substitution
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1021
|
|
1553.
|
|
|
The simplest expression is just a variable substitution. The syntax for this is the ${} construct instead of [[ ]] in rml.
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1023
|
|
1554.
|
|
|
eg::
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1025
../../source/developer/05_reports.rst:1037
|
|
1555.
|
|
|
In Mako, control structures (i.e. if/else, loops (like while and for), as well as things like try/except) are written using the % marker followed by a regular Python control expression, and are "closed" by using another % marker with the tag "end<name>", where "<name>" is the keyword of the expression:
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1035
|
|
1556.
|
|
|
Python Blocks
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1045
|
|
1557.
|
|
|
Within <% %>, you're writing a regular block of Python code. While the code can appear with an arbitrary level of preceding whitespace, it has to be consistently formatted with itself. Mako's compiler will adjust the block of Python to be consistent with the surrounding generated Python code.
|
|
|
|
(no translation yet)
|
|
|
|
Located in
../../source/developer/05_reports.rst:1047
|