Changes between Version 1 and Version 2 of Dev/Technical/UsingMako


Ignore:
Timestamp:
03/24/11 17:46:51 (3 years ago)
Author:
mdamarac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Dev/Technical/UsingMako

    v1 v2  
    2727}}} 
    2828Here {{{None}}} defines the default value for {{{dark}}}. 
     29 
     30Another 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. 
    2931 
    3032= 3. Whitespace between two expressions matters = 
     
    8486= 7. Continuous Python blocks should be merged into one = 
    8587Indico 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 = 
     90If 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}}} 
     94and 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}}} 
     98The variable {{{TPLS}}} is defined to be {{{Config.getInstance().getTPLDir()}}}.