Edgewall Software

Changes between Version 29 and Version 30 of TracDev/PortingFromGenshiToJinja


Ignore:
Timestamp:
Jan 6, 2017, 6:01:44 PM (7 years ago)
Author:
Christian Boos
Comment:

using #with to better "scope" the assignments made by set

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PortingFromGenshiToJinja

    v29 v30  
    308308See [http://jinja.pocoo.org/docs/dev/templates/#assignments set] and [http://jinja.pocoo.org/docs/dev/templates/#with-statement with] docs.
    309309
    310 In addition, be careful when using `with`: don't wrap a `block` directive within a `with`. If you want to set a global scope for the document (like in our <html> example above), it's tempting to use a single `with` statement, for clarity. But that would wrap all blocks defined in the template and strange results would ensue.
     310In addition, `with` can also be used to better control how the successive `set` on a given variable are being applied (see for example [1e25c852/cboos.git]).
     311
     312Finally be careful when using `with`: don't wrap a `block` directive within a `with`. If you want to set a global scope for the document (like in our <html> example above), it's tempting to use a single `with` statement, for clarity. But that would wrap all blocks defined in the template and strange results would ensue.
    311313
    312314