Edgewall Software

Changes between Version 25 and Version 26 of MarkupTemplates


Ignore:
Timestamp:
Jul 28, 2006, 8:22:34 PM (18 years ago)
Author:
cmlenz
Comment:

Document the new py:with directive

Legend:

Unmodified
Added
Removed
Modified
  • MarkupTemplates

    v25 v26  
    378378}}}
    379379
     380=== `py:with` ===
     381
     382The `py:with` directive lets you assign expressions to variables, which can be used to make expressions inside the directive less verbose and more efficient. For example, if you need use the expression `author.posts` more than once, and that actually results in a database query, assigning the results to a variable using this directive would probably help.
     383
     384For example:
     385
     386{{{
     387#!xml
     388<div xmlns:py="http://markup.edgewall.org/">
     389  <span py:with="y=7; z=x+10">$x $y $z</span>
     390</div>
     391}}}
     392
     393Given `x=42` in the context data, this would produce:
     394
     395{{{
     396#!xml
     397<div>
     398  <span>42 7 52</span>
     399</div>
     400}}}
     401
     402This directive can also be used as an element:
     403
     404{{{
     405#!xml
     406<div xmlns:py="http://markup.edgewall.org/">
     407  <py:with vars="y=7; z=x+10">$x $y $z</py:with>
     408</div>
     409}}}
     410
    380411=== `py:match` ===
    381412