Changes between Version 4 and Version 5 of TracDev/PortingFromGenshiToJinja
- Timestamp:
- Feb 22, 2016, 9:39:58 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/PortingFromGenshiToJinja
v4 v5 36 36 37 37 However, Jinja2 expressions are only //similar// to Python expressions, there are a few differences and limitations, see [http://jinja.pocoo.org/docs/dev/templates/#expressions expressions] doc. 38 39 See also [#setcomplexvariabels set complex variables] below for more involved examples. 38 40 39 41 === include another template … … 210 212 }}} 211 213 214 If you wonder why the `if all(...)` expression morphed into `if not components|...`, it's because Jinja2 expressions are similar to Python expressions, but not quite the same. 215 216 === set complex variables 212 217 Note that Jinja2 expressions are a subset of Python expressions, and for the sake of simplicity the generator expressions are not part of that subset. This limitation often requires one to make creative use of [http://jinja.pocoo.org/docs/dev/templates/#filters filters], [http://jinja.pocoo.org/docs/dev/templates/#builtin-filters built-in] or custom (`min`, `max`, `trim`, `flatten`). 213 218 … … 217 222 || `${', '.join([p.name for p in faulty_plugins])}` || \ 218 223 || `${faulty_plugins|map('name')|join(', ')}` || 224 || `sum(1 for change in changes if 'cnum' in change)` || \ 225 || `changes|selectattr('cnum')|list|count` || 226 || `sum(1 for change in changes if 'cnum' not in change)` || \ 227 || `changes|rejectattr('cnum')|list|count` || 219 228 || ... || ... || 220 229