Mercurial > genshi > genshi-test
annotate doc/xml-templates.txt @ 902:09cc3627654c experimental-inline
Sync `experimental/inline` branch with [source:trunk@1126].
author | cmlenz |
---|---|
date | Fri, 23 Apr 2010 21:08:26 +0000 |
parents | 1837f39efd6f |
children |
rev | line source |
---|---|
226 | 1 .. -*- mode: rst; encoding: utf-8 -*- |
2 | |
3 ============================ | |
230 | 4 Genshi XML Template Language |
226 | 5 ============================ |
6 | |
241
bbed6d426678
* Added basic documentation for the text-based template language.
cmlenz
parents:
237
diff
changeset
|
7 Genshi provides a XML-based template language that is heavily inspired by Kid_, |
bbed6d426678
* Added basic documentation for the text-based template language.
cmlenz
parents:
237
diff
changeset
|
8 which in turn was inspired by a number of existing template languages, namely |
bbed6d426678
* Added basic documentation for the text-based template language.
cmlenz
parents:
237
diff
changeset
|
9 XSLT_, TAL_, and PHP_. |
226 | 10 |
11 .. _kid: http://kid-templating.org/ | |
12 .. _python: http://www.python.org/ | |
13 .. _xslt: http://www.w3.org/TR/xslt | |
14 .. _tal: http://www.zope.org/Wikis/DevSite/Projects/ZPT/TAL | |
15 .. _php: http://www.php.net/ | |
16 | |
17 This document describes the template language and will be most useful as | |
241
bbed6d426678
* Added basic documentation for the text-based template language.
cmlenz
parents:
237
diff
changeset
|
18 reference to those developing Genshi XML templates. Templates are XML files of |
bbed6d426678
* Added basic documentation for the text-based template language.
cmlenz
parents:
237
diff
changeset
|
19 some kind (such as XHTML) that include processing directives_ (elements or |
226 | 20 attributes identified by a separate namespace) that affect how the template is |
500 | 21 rendered, and template expressions that are dynamically substituted by |
226 | 22 variable data. |
23 | |
500 | 24 See `Genshi Templating Basics <templates.html>`_ for general information on |
25 embedding Python code in templates. | |
26 | |
226 | 27 |
28 .. contents:: Contents | |
29 :depth: 3 | |
30 .. sectnum:: | |
31 | |
32 | |
33 .. _`directives`: | |
34 | |
35 ------------------- | |
36 Template Directives | |
37 ------------------- | |
38 | |
39 Directives are elements and/or attributes in the template that are identified | |
230 | 40 by the namespace ``http://genshi.edgewall.org/``. They can affect how the |
41 template is rendered in a number of ways: Genshi provides directives for | |
226 | 42 conditionals and looping, among others. |
43 | |
395 | 44 To use directives in a template, the namespace must be declared, which is |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
45 usually done on the root element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
46 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
47 .. code-block:: genshi |
226 | 48 |
49 <html xmlns="http://www.w3.org/1999/xhtml" | |
230 | 50 xmlns:py="http://genshi.edgewall.org/" |
226 | 51 lang="en"> |
52 ... | |
53 </html> | |
54 | |
55 In this example, the default namespace is set to the XHTML namespace, and the | |
230 | 56 namespace for Genshi directives is bound to the prefix “py”. |
226 | 57 |
58 All directives can be applied as attributes, and some can also be used as | |
59 elements. The ``if`` directives for conditionals, for example, can be used in | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
60 both ways: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
61 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
62 .. code-block:: genshi |
226 | 63 |
64 <html xmlns="http://www.w3.org/1999/xhtml" | |
230 | 65 xmlns:py="http://genshi.edgewall.org/" |
226 | 66 lang="en"> |
67 ... | |
68 <div py:if="foo"> | |
69 <p>Bar</p> | |
70 </div> | |
71 ... | |
72 </html> | |
73 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
74 This is basically equivalent to the following: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
75 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
76 .. code-block:: genshi |
226 | 77 |
78 <html xmlns="http://www.w3.org/1999/xhtml" | |
230 | 79 xmlns:py="http://genshi.edgewall.org/" |
226 | 80 lang="en"> |
81 ... | |
82 <py:if test="foo"> | |
83 <div> | |
84 <p>Bar</p> | |
85 </div> | |
86 </py:if> | |
87 ... | |
88 </html> | |
89 | |
90 The rationale behind the second form is that directives do not always map | |
91 naturally to elements in the template. In such cases, the ``py:strip`` | |
92 directive can be used to strip off the unwanted element, or the directive can | |
93 simply be used as an element. | |
94 | |
95 | |
237 | 96 Conditional Sections |
226 | 97 ==================== |
98 | |
235 | 99 .. _`py:if`: |
226 | 100 |
235 | 101 ``py:if`` |
237 | 102 --------- |
226 | 103 |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
104 The element and its content is only rendered if the expression evaluates to a |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
105 truth value: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
106 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
107 .. code-block:: genshi |
226 | 108 |
235 | 109 <div> |
110 <b py:if="foo">${bar}</b> | |
111 </div> | |
226 | 112 |
235 | 113 Given the data ``foo=True`` and ``bar='Hello'`` in the template context, this |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
114 would produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
115 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
116 .. code-block:: xml |
235 | 117 |
118 <div> | |
119 <b>Hello</b> | |
120 </div> | |
121 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
122 But setting ``foo=False`` would result in the following output: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
123 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
124 .. code-block:: xml |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
125 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
126 <div> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
127 </div> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
128 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
129 This directive can also be used as an element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
130 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
131 .. code-block:: genshi |
235 | 132 |
133 <div> | |
134 <py:if test="foo"> | |
135 <b>${bar}</b> | |
136 </py:if> | |
137 </div> | |
226 | 138 |
139 .. _`py:choose`: | |
140 .. _`py:when`: | |
141 .. _`py:otherwise`: | |
142 | |
237 | 143 ``py:choose`` |
144 ------------- | |
226 | 145 |
237 | 146 The ``py:choose`` directive, in combination with the directives ``py:when`` |
500 | 147 and ``py:otherwise`` provides advanced conditional processing for rendering one |
226 | 148 of several alternatives. The first matching ``py:when`` branch is rendered, or, |
500 | 149 if no ``py:when`` branch matches, the ``py:otherwise`` branch is rendered. |
226 | 150 |
151 If the ``py:choose`` directive is empty the nested ``py:when`` directives will | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
152 be tested for truth: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
153 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
154 .. code-block:: genshi |
226 | 155 |
156 <div py:choose=""> | |
157 <span py:when="0 == 1">0</span> | |
158 <span py:when="1 == 1">1</span> | |
159 <span py:otherwise="">2</span> | |
160 </div> | |
161 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
162 This would produce the following output: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
163 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
164 .. code-block:: xml |
226 | 165 |
166 <div> | |
167 <span>1</span> | |
168 </div> | |
169 | |
170 If the ``py:choose`` directive contains an expression the nested ``py:when`` | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
171 directives will be tested for equality to the parent ``py:choose`` value: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
172 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
173 .. code-block:: genshi |
226 | 174 |
175 <div py:choose="1"> | |
176 <span py:when="0">0</span> | |
177 <span py:when="1">1</span> | |
178 <span py:otherwise="">2</span> | |
179 </div> | |
180 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
181 This would produce the following output: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
182 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
183 .. code-block:: xml |
226 | 184 |
185 <div> | |
186 <span>1</span> | |
187 </div> | |
188 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
189 These directives can also be used as elements: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
190 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
191 .. code-block:: genshi |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
192 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
193 <py:choose test="1"> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
194 <py:when test="0">0</py:when> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
195 <py:when test="1">1</py:when> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
196 <py:otherwise>2</py:otherwise> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
197 </py:choose> |
226 | 198 |
235 | 199 Looping |
237 | 200 ======= |
226 | 201 |
235 | 202 .. _`py:for`: |
226 | 203 |
235 | 204 ``py:for`` |
237 | 205 ---------- |
235 | 206 |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
207 The element is repeated for every item in an iterable: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
208 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
209 .. code-block:: genshi |
226 | 210 |
211 <ul> | |
235 | 212 <li py:for="item in items">${item}</li> |
226 | 213 </ul> |
214 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
215 Given ``items=[1, 2, 3]`` in the context data, this would produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
216 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
217 .. code-block:: xml |
226 | 218 |
219 <ul> | |
235 | 220 <li>1</li><li>2</li><li>3</li> |
226 | 221 </ul> |
222 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
223 This directive can also be used as an element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
224 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
225 .. code-block:: genshi |
226 | 226 |
235 | 227 <ul> |
228 <py:for each="item in items"> | |
229 <li>${item}</li> | |
230 </py:for> | |
231 </ul> | |
232 | |
233 | |
234 Snippet Reuse | |
237 | 235 ============= |
226 | 236 |
237 .. _`py:def`: | |
238 .. _`macros`: | |
239 | |
240 ``py:def`` | |
237 | 241 ---------- |
226 | 242 |
243 The ``py:def`` directive can be used to create macros, i.e. snippets of | |
244 template code that have a name and optionally some parameters, and that can be | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
245 inserted in other places: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
246 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
247 .. code-block:: genshi |
226 | 248 |
249 <div> | |
250 <p py:def="greeting(name)" class="greeting"> | |
251 Hello, ${name}! | |
252 </p> | |
253 ${greeting('world')} | |
254 ${greeting('everyone else')} | |
255 </div> | |
256 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
257 The above would be rendered to: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
258 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
259 .. code-block:: xml |
226 | 260 |
261 <div> | |
262 <p class="greeting"> | |
263 Hello, world! | |
264 </p> | |
265 <p class="greeting"> | |
266 Hello, everyone else! | |
267 </p> | |
268 </div> | |
269 | |
395 | 270 If a macro doesn't require parameters, it can be defined without the |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
271 parenthesis. For example: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
272 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
273 .. code-block:: genshi |
226 | 274 |
275 <div> | |
276 <p py:def="greeting" class="greeting"> | |
277 Hello, world! | |
278 </p> | |
395 | 279 ${greeting()} |
226 | 280 </div> |
281 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
282 The above would be rendered to: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
283 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
284 .. code-block:: xml |
226 | 285 |
286 <div> | |
287 <p class="greeting"> | |
288 Hello, world! | |
289 </p> | |
290 </div> | |
291 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
292 This directive can also be used as an element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
293 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
294 .. code-block:: genshi |
226 | 295 |
296 <div> | |
297 <py:def function="greeting(name)"> | |
298 <p class="greeting">Hello, ${name}!</p> | |
299 </py:def> | |
300 </div> | |
301 | |
302 | |
235 | 303 .. _Match Templates: |
226 | 304 .. _`py:match`: |
305 | |
306 ``py:match`` | |
237 | 307 ------------ |
226 | 308 |
309 This directive defines a *match template*: given an XPath expression, it | |
310 replaces any element in the template that matches the expression with its own | |
311 content. | |
312 | |
313 For example, the match template defined in the following template matches any | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
314 element with the tag name “greeting”: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
315 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
316 .. code-block:: genshi |
226 | 317 |
318 <div> | |
319 <span py:match="greeting"> | |
320 Hello ${select('@name')} | |
321 </span> | |
322 <greeting name="Dude" /> | |
323 </div> | |
324 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
325 This would result in the following output: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
326 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
327 .. code-block:: xml |
226 | 328 |
329 <div> | |
330 <span> | |
331 Hello Dude | |
332 </span> | |
333 </div> | |
334 | |
335 Inside the body of a ``py:match`` directive, the ``select(path)`` function is | |
336 made available so that parts or all of the original element can be incorporated | |
500 | 337 in the output of the match template. See `Using XPath`_ for more information |
338 about this function. | |
339 | |
340 .. _`Using XPath`: streams.html#using-xpath | |
226 | 341 |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
342 Match templates are applied both to the original markup as well to the |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
343 generated markup. The order in which they are applied depends on the order |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
344 they are declared in the template source: a match template defined after |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
345 another match template is applied to the output generated by the first match |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
346 template. The match templates basically form a pipeline. |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
347 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
348 This directive can also be used as an element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
349 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
350 .. code-block:: genshi |
226 | 351 |
352 <div> | |
353 <py:match path="greeting"> | |
354 <span>Hello ${select('@name')}</span> | |
355 </py:match> | |
356 <greeting name="Dude" /> | |
357 </div> | |
358 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
359 When used this way, the ``py:match`` directive can also be annotated with a |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
360 couple of optimization hints. For example, the following informs the matching |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
361 engine that the match should only be applied once: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
362 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
363 .. code-block:: genshi |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
364 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
365 <py:match path="body" once="true"> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
366 <body py:attrs="select('@*')"> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
367 <div id="header">...</div> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
368 ${select("*|text()")} |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
369 <div id="footer">...</div> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
370 </body> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
371 </py:match> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
372 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
373 The following optimization hints are recognized: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
374 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
375 +---------------+-----------+-----------------------------------------------+ |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
376 | Attribute | Default | Description | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
377 +===============+===========+===============================================+ |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
378 | ``buffer`` | ``true`` | Whether the matched content should be | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
379 | | | buffered in memory. Buffering can improve | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
380 | | | performance a bit at the cost of needing more | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
381 | | | memory during rendering. Buffering is | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
382 | | | ''required'' for match templates that contain | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
383 | | | more than one invocation of the ``select()`` | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
384 | | | function. If there is only one call, and the | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
385 | | | matched content can potentially be very long, | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
386 | | | consider disabling buffering to avoid | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
387 | | | excessive memory use. | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
388 +---------------+-----------+-----------------------------------------------+ |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
389 | ``once`` | ``false`` | Whether the engine should stop looking for | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
390 | | | more matching elements after the first match. | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
391 | | | Use this on match templates that match | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
392 | | | elements that can only occur once in the | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
393 | | | stream, such as the ``<head>`` or ``<body>`` | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
394 | | | elements in an HTML template, or elements | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
395 | | | with a specific ID. | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
396 +---------------+-----------+-----------------------------------------------+ |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
397 | ``recursive`` | ``true`` | Whether the match template should be applied | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
398 | | | to its own output. Note that ``once`` implies | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
399 | | | non-recursive behavior, so this attribute | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
400 | | | only needs to be set for match templates that | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
401 | | | don't also have ``once`` set. | |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
402 +---------------+-----------+-----------------------------------------------+ |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
403 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
404 .. note:: The ``py:match`` optimization hints were added in the 0.5 release. In |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
405 earlier versions, the attributes have no effect. |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
406 |
226 | 407 |
235 | 408 Variable Binding |
237 | 409 ================ |
226 | 410 |
411 .. _`with`: | |
412 | |
413 ``py:with`` | |
237 | 414 ----------- |
226 | 415 |
416 The ``py:with`` directive lets you assign expressions to variables, which can | |
417 be used to make expressions inside the directive less verbose and more | |
418 efficient. For example, if you need use the expression ``author.posts`` more | |
419 than once, and that actually results in a database query, assigning the results | |
420 to a variable using this directive would probably help. | |
421 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
422 For example: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
423 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
424 .. code-block:: genshi |
226 | 425 |
426 <div> | |
427 <span py:with="y=7; z=x+10">$x $y $z</span> | |
428 </div> | |
429 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
430 Given ``x=42`` in the context data, this would produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
431 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
432 .. code-block:: xml |
226 | 433 |
434 <div> | |
435 <span>42 7 52</span> | |
436 </div> | |
437 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
438 This directive can also be used as an element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
439 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
440 .. code-block:: genshi |
226 | 441 |
442 <div> | |
443 <py:with vars="y=7; z=x+10">$x $y $z</py:with> | |
444 </div> | |
445 | |
446 Note that if a variable of the same name already existed outside of the scope | |
447 of the ``py:with`` directive, it will **not** be overwritten. Instead, it | |
448 will have the same value it had prior to the ``py:with`` assignment. | |
230 | 449 Effectively, this means that variables are immutable in Genshi. |
226 | 450 |
451 | |
235 | 452 Structure Manipulation |
237 | 453 ====================== |
235 | 454 |
455 .. _`py:attrs`: | |
456 | |
457 ``py:attrs`` | |
237 | 458 ------------ |
235 | 459 |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
460 This directive adds, modifies or removes attributes from the element: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
461 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
462 .. code-block:: genshi |
235 | 463 |
464 <ul> | |
465 <li py:attrs="foo">Bar</li> | |
466 </ul> | |
467 | |
468 Given ``foo={'class': 'collapse'}`` in the template context, this would | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
469 produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
470 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
471 .. code-block:: xml |
235 | 472 |
473 <ul> | |
474 <li class="collapse">Bar</li> | |
475 </ul> | |
476 | |
477 Attributes with the value ``None`` are omitted, so given ``foo={'class': None}`` | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
478 in the context for the same template this would produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
479 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
480 .. code-block:: xml |
235 | 481 |
482 <ul> | |
483 <li>Bar</li> | |
484 </ul> | |
485 | |
486 This directive can only be used as an attribute. | |
487 | |
488 | |
489 .. _`py:content`: | |
490 | |
491 ``py:content`` | |
237 | 492 -------------- |
235 | 493 |
494 This directive replaces any nested content with the result of evaluating the | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
495 expression: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
496 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
497 .. code-block:: genshi |
235 | 498 |
499 <ul> | |
500 <li py:content="bar">Hello</li> | |
501 </ul> | |
502 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
503 Given ``bar='Bye'`` in the context data, this would produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
504 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
505 .. code-block:: xml |
235 | 506 |
507 <ul> | |
508 <li>Bye</li> | |
509 </ul> | |
510 | |
511 This directive can only be used as an attribute. | |
512 | |
513 | |
514 .. _`py:replace`: | |
515 | |
516 ``py:replace`` | |
237 | 517 -------------- |
235 | 518 |
519 This directive replaces the element itself with the result of evaluating the | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
520 expression: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
521 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
522 .. code-block:: genshi |
235 | 523 |
524 <div> | |
525 <span py:replace="bar">Hello</span> | |
526 </div> | |
527 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
528 Given ``bar='Bye'`` in the context data, this would produce: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
529 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
530 .. code-block:: xml |
235 | 531 |
532 <div> | |
533 Bye | |
534 </div> | |
535 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
536 This directive can also be used as an element (since version 0.5): |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
537 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
538 .. code-block:: genshi |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
539 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
540 <div> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
541 <py:replace value="title">Placeholder</py:replace> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
542 </div> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
543 |
235 | 544 |
545 | |
546 .. _`py:strip`: | |
547 | |
548 ``py:strip`` | |
237 | 549 ------------ |
235 | 550 |
551 This directive conditionally strips the top-level element from the output. When | |
552 the value of the ``py:strip`` attribute evaluates to ``True``, the element is | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
553 stripped from the output: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
554 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
555 .. code-block:: genshi |
235 | 556 |
557 <div> | |
558 <div py:strip="True"><b>foo</b></div> | |
559 </div> | |
560 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
561 This would be rendered as: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
562 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
563 .. code-block:: xml |
235 | 564 |
565 <div> | |
566 <b>foo</b> | |
567 </div> | |
568 | |
569 As a shorthand, if the value of the ``py:strip`` attribute is empty, that has | |
570 the same effect as using a truth value (i.e. the element is stripped). | |
571 | |
572 | |
226 | 573 .. _order: |
574 | |
575 Processing Order | |
576 ================ | |
577 | |
578 It is possible to attach multiple directives to a single element, although not | |
579 all combinations make sense. When multiple directives are encountered, they are | |
580 processed in the following order: | |
581 | |
582 #. `py:def`_ | |
583 #. `py:match`_ | |
584 #. `py:when`_ | |
585 #. `py:otherwise`_ | |
586 #. `py:for`_ | |
587 #. `py:if`_ | |
588 #. `py:choose`_ | |
589 #. `py:with`_ | |
590 #. `py:replace`_ | |
591 #. `py:content`_ | |
592 #. `py:attrs`_ | |
593 #. `py:strip`_ | |
594 | |
595 | |
596 .. _includes: | |
597 | |
598 -------- | |
599 Includes | |
600 -------- | |
601 | |
602 To reuse common snippets of template code, you can include other files using | |
603 XInclude_. | |
604 | |
605 .. _xinclude: http://www.w3.org/TR/xinclude/ | |
606 | |
607 For this, you need to declare the XInclude namespace (commonly bound to the | |
608 prefix “xi”) and use the ``<xi:include>`` element where you want the external | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
609 file to be pulled in: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
610 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
611 .. code-block:: genshi |
226 | 612 |
613 <html xmlns="http://www.w3.org/1999/xhtml" | |
230 | 614 xmlns:py="http://genshi.edgewall.org/" |
226 | 615 xmlns:xi="http://www.w3.org/2001/XInclude"> |
616 <xi:include href="base.html" /> | |
617 ... | |
618 </html> | |
619 | |
620 Include paths are relative to the filename of the template currently being | |
621 processed. So if the example above was in the file "``myapp/index.html``" | |
622 (relative to the template search path), the XInclude processor would look for | |
623 the included file at "``myapp/base.html``". You can also use Unix-style | |
624 relative paths, for example "``../base.html``" to look in the parent directory. | |
625 | |
626 Any content included this way is inserted into the generated output instead of | |
627 the ``<xi:include>`` element. The included template sees the same context data. | |
628 `Match templates`_ and `macros`_ in the included template are also available to | |
629 the including template after the point it was included. | |
630 | |
631 By default, an error will be raised if an included file is not found. If that's | |
632 not what you want, you can specify fallback content that should be used if the | |
633 include fails. For example, to to make the include above fail silently, you'd | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
634 write: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
635 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
636 .. code-block:: genshi |
226 | 637 |
638 <xi:include href="base.html"><xi:fallback /></xi:include> | |
639 | |
273 | 640 See the `XInclude specification`_ for more about fallback content. Note though |
641 that Genshi currently only supports a small subset of XInclude. | |
642 | |
643 .. _`xinclude specification`: http://www.w3.org/TR/xinclude/ | |
226 | 644 |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
645 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
646 Dynamic Includes |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
647 ================ |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
648 |
230 | 649 Incudes in Genshi are fully dynamic: Just like normal attributes, the `href` |
500 | 650 attribute accepts expressions, and directives_ can be used on the |
226 | 651 ``<xi:include />`` element just as on any other element, meaning you can do |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
652 things like conditional includes: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
653 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
654 .. code-block:: genshi |
226 | 655 |
656 <xi:include href="${name}.html" py:if="not in_popup" | |
657 py:for="name in ('foo', 'bar', 'baz')" /> | |
658 | |
659 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
660 Including Text Templates |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
661 ======================== |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
662 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
663 The ``parse`` attribute of the ``<xi:include>`` element can be used to specify |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
664 whether the included template is an XML template or a text template (using the |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
665 new syntax added in Genshi 0.5): |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
666 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
667 .. code-block:: genshi |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
668 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
669 <xi:include href="myscript.js" parse="text" /> |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
670 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
671 This example would load the ``myscript.js`` file as a ``NewTextTemplate``. See |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
672 `text templates`_ for details on the syntax of text templates. |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
673 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
674 .. _`text templates`: text-templates.html |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
675 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
676 |
226 | 677 .. _comments: |
678 | |
679 -------- | |
680 Comments | |
681 -------- | |
682 | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
683 Normal XML/HTML comment syntax can be used in templates: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
684 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
685 .. code-block:: genshi |
226 | 686 |
687 <!-- this is a comment --> | |
688 | |
689 However, such comments get passed through the processing pipeline and are by | |
690 default included in the final output. If that's not desired, prefix the comment | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
691 text with an exclamation mark: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
692 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
693 .. code-block:: genshi |
226 | 694 |
695 <!-- !this is a comment too, but one that will be stripped from the output --> | |
696 | |
697 Note that it does not matter whether there's whitespace before or after the | |
820
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
698 exclamation mark, so the above could also be written as follows: |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
699 |
1837f39efd6f
Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents:
500
diff
changeset
|
700 .. code-block:: genshi |
226 | 701 |
702 <!--! this is a comment too, but one that will be stripped from the output --> |