Mercurial > genshi > genshi-test
comparison doc/xml-templates.txt @ 602:509b3a5e765e
Add runtime optimization hints for match templates.
author | cmlenz |
---|---|
date | Thu, 23 Aug 2007 11:35:43 +0000 |
parents | ca7d707d51b0 |
children | 6a37018199fd |
comparison
equal
deleted
inserted
replaced
601:9ae986bcba9a | 602:509b3a5e765e |
---|---|
330 <py:match path="greeting"> | 330 <py:match path="greeting"> |
331 <span>Hello ${select('@name')}</span> | 331 <span>Hello ${select('@name')}</span> |
332 </py:match> | 332 </py:match> |
333 <greeting name="Dude" /> | 333 <greeting name="Dude" /> |
334 </div> | 334 </div> |
335 | |
336 When used this way, the ``py:match`` directive can also be annotated with a | |
337 couple of optimization hints. For example, the following informs the matching | |
338 engine that the match should only be applied once: | |
339 | |
340 .. code-block:: genshi | |
341 | |
342 <py:match path="body" once="true"> | |
343 <body py:attrs="select('@*')"> | |
344 <div id="header">...</div> | |
345 ${select("*|text()")} | |
346 <div id="footer">...</div> | |
347 </body> | |
348 </py:match> | |
349 | |
350 The following optimization hints are recognized: | |
351 | |
352 +---------------+-----------+-----------------------------------------------+ | |
353 | Attribute | Default | Description | | |
354 +===============+===========+===============================================+ | |
355 | ``once`` | ``false`` | Whether the engine should stop looking for | | |
356 | | | more matching elements after the first match. | | |
357 | | | Use this on match templates that match | | |
358 | | | elements that can only occur once in the | | |
359 | | | stream, such as the ``<head>`` or ``<body>`` | | |
360 | | | elements in an HTML template, or elements | | |
361 | | | with a specific ID. | | |
362 +---------------+-----------+-----------------------------------------------+ | |
363 | ``recursive`` | ``true`` | Whether the match template should be applied | | |
364 | | | to its own output. Note that ``once`` implies | | |
365 | | | non-recursive behavior, so this attribute | | |
366 | | | only needs to be set for match templates that | | |
367 | | | don't also have ``once`` set. | | |
368 +---------------+-----------+-----------------------------------------------+ | |
369 | |
370 .. note:: The ``py:match`` optimization hints were added in the 0.5 release. In | |
371 earlier versions, the attributes have no effect. | |
335 | 372 |
336 | 373 |
337 Variable Binding | 374 Variable Binding |
338 ================ | 375 ================ |
339 | 376 |