Changes between Version 1 and Version 2 of Dev/Technical/UsingMako
- Timestamp:
- 03/24/11 17:46:51 (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Dev/Technical/UsingMako
v1 v2 27 27 }}} 28 28 Here {{{None}}} defines the default value for {{{dark}}}. 29 30 Another important thing is that only the arguments that were passed to the {{{render()}}} method get passed along to the included templates. Local variables or {{{pageargs}}} from some template {{{A.tpl}}} will not be available in all the templates that {{{A.tpl}}} includes. 29 31 30 32 = 3. Whitespace between two expressions matters = … … 84 86 = 7. Continuous Python blocks should be merged into one = 85 87 Indico template [[https://espace.cern.ch/indico-soft/developers/wiki%20for%20Indico%20developers/Templating%20engine%20guide.aspx|documentation]] recommends to surround each Python code line with {{{<% %>}}}. Mako generates faster code when continuous {{{<% %>}}} blocks are merged into one. This is because after {{{<% %>}}} Python code execution Mako updates a dictionary where it keeps some information about the variables. 88 89 = 8. Search path in inclusion mechanism = 90 If the template {{{A.tpl}}} includes another template using {{{<%include file="B.tpl"/>}}}, then Mako searches for {{{B.tpl}}} in the same directory where {{{A.tpl}}} is stored. This becomes a problem, for example, when a template in the plugins folder tries to do, 91 {{{ 92 <%include file="ConfModifCollaborationDefaultAdvancedTab.tpl"/> 93 }}} 94 and the file to be included is in the main templates directory. The problem can be solved by using full path: 95 {{{ 96 <%include file="${TPLS}/ConfModifCollaborationDefaultAdvancedTab.tpl"/> 97 }}} 98 The variable {{{TPLS}}} is defined to be {{{Config.getInstance().getTPLDir()}}}.
