Changes between Version 20 and Version 21 of MarkupTemplates
- Timestamp:
- Jul 11, 2006, 10:17:26 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MarkupTemplates
v20 v21 178 178 === `py:strip` === 179 179 180 This directive conditionally strips the top-level element from the output. When the value of the `py:strip` attribute evaluates to `True`, the element 181 is stripped from the output: 182 183 {{{ 184 #!xml 185 <div xmlns:py="http://markup.edgewall.org/"> 186 <div py:strip="True"><b>foo</b></div> 187 </div> 188 }}} 189 190 This would be rendered as: 191 192 {{{ 193 #!xml 194 <div> 195 <b>foo</b> 196 </div> 197 }}} 198 199 As a shorthand, if the value of the `py:strip` attribute is empty, that has the same effect as using a truth value (i.e. the element is stripped). 200 180 201 === `py:if` === 181 202 182 203 The element is only rendered if the expression evaluates to a truth value. 204 205 {{{ 206 #!xml 207 <div xmlns:py="http://markup.edgewall.org/"> 208 <b py:if="foo">${bar}</b> 209 </div> 210 }}} 211 212 Given the data `{'foo'=True, 'bar'='Hello'}` in the template context, this would produce: 213 214 {{{ 215 #!xml 216 <div> 217 <b>Hello</b> 218 </div> 219 }}} 220 221 This directive can also be used as an element: 222 223 {{{ 224 #!xml 225 <div xmlns:py="http://markup.edgewall.org/"> 226 <py:if test="foo"> 227 <b>${bar}</b> 228 </py:if> 229 </div> 230 }}} 231 183 232 184 233 === `py:choose` / `py:when` / `py:otherwise` === … … 302 351 }}} 303 352 353 Inside the body of a `py:match` directive, the `select(path)` function is made available so that parts or all of the original element can be incorporated in the output of the match template. See [wiki:MarkupStream#UsingXPath] for more information about this function. 354 304 355 This directive can also be used as an element: 305 356