Edgewall Software

Changes between Version 3 and Version 4 of TracDev/PortingFromGenshiToJinja


Ignore:
Timestamp:
Feb 22, 2016, 9:15:37 PM (8 years ago)
Author:
Christian Boos
Comment:

#includeanothertemplate with parameters

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PortingFromGenshiToJinja

    v3 v4  
    4242
    4343See [http://jinja.pocoo.org/docs/dev/templates/#include include] doc.
     44
     45It is also possible to pass "parameters" to included templates.
     46Those are not actually declared parameters, simply variables expected to be available in the template that can be set for the scope of one specific include. This works exactly like in Genshi, with a with statement:
     47
     48 - Genshi
     49   {{{#!html+genshi
     50        <xi:include href="ticket_box.html" py:with="can_append = False; preview_mode = False"/>
     51   }}}
     52 - Jinja
     53   {{{#!html+jinja
     54      # with
     55      #   set can_append = false
     56      #   set preview_mode = false
     57      #   include "jticket_box.html"
     58      # endwith
     59   }}}
     60
     61See [http://jinja.pocoo.org/docs/dev/extensions/#with-statement with] doc.
     62
     63Caveat: note how the boolean constants slightly differ from Python, `False` becomes `false`, `True` becomes `true` and `None` is `none`.
    4464
    4565=== simple if...then (no else)