1
<?xml version="1.0" encoding="ascii"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
"DTD/xhtml1-transitional.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<title>genshi.template.directives.IfDirective</title>
7
<link rel="stylesheet" href="epydoc.css" type="text/css" />
8
<script type="text/javascript" src="epydoc.js"></script>
11
<body bgcolor="white" text="black" link="blue" vlink="#204080"
13
<!-- ==================== NAVIGATION BAR ==================== -->
14
<table class="navbar" border="0" width="100%" cellpadding="0"
15
bgcolor="#a0c0ff" cellspacing="0">
18
<th> <a
19
href="genshi-module.html">Home</a> </th>
22
<th> <a
23
href="module-tree.html">Trees</a> </th>
26
<th> <a
27
href="identifier-index.html">Indices</a> </th>
30
<th> <a
31
href="help.html">Help</a> </th>
33
<!-- Project homepage -->
34
<th class="navbar" align="right" width="100%">
35
<table border="0" cellpadding="0" cellspacing="0">
36
<tr><th class="navbar" align="center"
37
><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
41
<table width="100%" cellpadding="0" cellspacing="0">
44
<span class="breadcrumbs">
45
<a href="genshi-module.html">Package genshi</a> ::
46
<a href="genshi.template-module.html">Package template</a> ::
47
<a href="genshi.template.directives-module.html">Module directives</a> ::
48
Class IfDirective
52
<table cellpadding="0" cellspacing="0">
53
<!-- hide/show private -->
58
<!-- ==================== CLASS DESCRIPTION ==================== -->
59
<h1 class="epydoc">Class IfDirective</h1><br /><br />
60
<pre class="base-tree">
65
<strong class="uidshort">IfDirective</strong>
69
<p>Implementation of the <tt class="rst-rst-rst-docutils literal rst-rst-docutils literal rst-docutils literal"><span class="pre">py:if</span></tt> template directive for conditionally
70
excluding elements from being output.</p>
71
<pre class="py-doctest">
72
<span class="py-prompt">>>> </span><span class="py-keyword">from</span> genshi.template <span class="py-keyword">import</span> MarkupTemplate
73
<span class="py-prompt">>>> </span>tmpl = MarkupTemplate(<span class="py-string">'''<div xmlns:py="http://genshi.edgewall.org/"></span>
74
<span class="py-more">... </span><span class="py-string"> <b py:if="foo">${bar}</b></span>
75
<span class="py-more">... </span><span class="py-string"></div>'''</span>)
76
<span class="py-prompt">>>> </span><span class="py-keyword">print</span> tmpl.generate(foo=True, bar=<span class="py-string">'Hello'</span>)
77
<span class="py-output"><div></span>
78
<span class="py-output"> <b>Hello</b></span>
79
<span class="py-output"></div></span></pre><br /><br />
81
<!-- ==================== NESTED CLASSES ==================== -->
82
<a name="section-NestedClasses"></a>
83
<table class="summary" border="1" cellpadding="3"
84
cellspacing="0" width="100%" bgcolor="white">
85
<tr bgcolor="#70b0f0" class="table-header">
86
<td align="left" colspan="2" class="table-header">
87
<span class="table-header">Nested Classes</span></td>
90
<td colspan="2" class="summary">
91
<p class="indent-wrapped-lines"><b>Inherited from <code>Directive</code></b>:
92
<code><a href="genshi.template.directives.DirectiveMeta-class.html">__metaclass__</a></code>
97
<!-- ==================== INSTANCE METHODS ==================== -->
98
<a name="section-InstanceMethods"></a>
99
<table class="summary" border="1" cellpadding="3"
100
cellspacing="0" width="100%" bgcolor="white">
101
<tr bgcolor="#70b0f0" class="table-header">
102
<td align="left" colspan="2" class="table-header">
103
<span class="table-header">Instance Methods</span></td>
106
<td width="15%" align="right" valign="top" class="summary">
107
<span class="summary-type"> </span>
108
</td><td class="summary">
109
<table width="100%" cellpadding="0" cellspacing="0" border="0">
111
<td><span class="summary-sig"><a href="genshi.template.directives.IfDirective-class.html#__call__" class="summary-sig-name">__call__</a>(<span class="summary-sig-arg">self</span>,
112
<span class="summary-sig-arg">stream</span>,
113
<span class="summary-sig-arg">ctxt</span>,
114
<span class="summary-sig-arg">directives</span>)</span><br />
115
Apply the directive to the given stream.</td>
116
<td align="right" valign="top">
126
<td colspan="2" class="summary">
127
<p class="indent-wrapped-lines"><b>Inherited from <code>Directive</code></b>:
128
<code>__init__</code>,
129
<code>__repr__</code>
131
<p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
132
<code>__delattr__</code>,
133
<code>__getattribute__</code>,
134
<code>__hash__</code>,
135
<code>__new__</code>,
136
<code>__reduce__</code>,
137
<code>__reduce_ex__</code>,
138
<code>__setattr__</code>,
144
<!-- ==================== CLASS METHODS ==================== -->
145
<a name="section-ClassMethods"></a>
146
<table class="summary" border="1" cellpadding="3"
147
cellspacing="0" width="100%" bgcolor="white">
148
<tr bgcolor="#70b0f0" class="table-header">
149
<td align="left" colspan="2" class="table-header">
150
<span class="table-header">Class Methods</span></td>
153
<td colspan="2" class="summary">
154
<p class="indent-wrapped-lines"><b>Inherited from <code>Directive</code></b>:
160
<!-- ==================== CLASS VARIABLES ==================== -->
161
<a name="section-ClassVariables"></a>
162
<table class="summary" border="1" cellpadding="3"
163
cellspacing="0" width="100%" bgcolor="white">
164
<tr bgcolor="#70b0f0" class="table-header">
165
<td align="left" colspan="2" class="table-header">
166
<span class="table-header">Class Variables</span></td>
169
<td width="15%" align="right" valign="top" class="summary">
170
<span class="summary-type"> </span>
171
</td><td class="summary">
172
<a name="ATTRIBUTE"></a><span class="summary-name">ATTRIBUTE</span> = <code title="'test'"><code class="variable-quote">'</code><code class="variable-string">test</code><code class="variable-quote">'</code></code>
176
<td width="15%" align="right" valign="top" class="summary">
177
<span class="summary-type"> </span>
178
</td><td class="summary">
179
<a name="tagname"></a><span class="summary-name">tagname</span> = <code title="'if'"><code class="variable-quote">'</code><code class="variable-string">if</code><code class="variable-quote">'</code></code>
183
<!-- ==================== PROPERTIES ==================== -->
184
<a name="section-Properties"></a>
185
<table class="summary" border="1" cellpadding="3"
186
cellspacing="0" width="100%" bgcolor="white">
187
<tr bgcolor="#70b0f0" class="table-header">
188
<td align="left" colspan="2" class="table-header">
189
<span class="table-header">Properties</span></td>
192
<td colspan="2" class="summary">
193
<p class="indent-wrapped-lines"><b>Inherited from <code>Directive</code></b>:
196
<p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
197
<code>__class__</code>
202
<!-- ==================== METHOD DETAILS ==================== -->
203
<a name="section-MethodDetails"></a>
204
<table class="details" border="1" cellpadding="3"
205
cellspacing="0" width="100%" bgcolor="white">
206
<tr bgcolor="#70b0f0" class="table-header">
207
<td align="left" colspan="2" class="table-header">
208
<span class="table-header">Method Details</span></td>
211
<a name="__call__"></a>
213
<table class="details" border="1" cellpadding="3"
214
cellspacing="0" width="100%" bgcolor="white">
216
<table width="100%" cellpadding="0" cellspacing="0" border="0">
217
<tr valign="top"><td>
218
<h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
219
<span class="sig-arg">stream</span>,
220
<span class="sig-arg">ctxt</span>,
221
<span class="sig-arg">directives</span>)</span>
222
<br /><em class="fname">(Call operator)</em>
224
</td><td align="right" valign="top"
229
Apply the directive to the given stream.
233
<dd><em class="note">(inherited documentation)</em></dd>
239
<!-- ==================== NAVIGATION BAR ==================== -->
240
<table class="navbar" border="0" width="100%" cellpadding="0"
241
bgcolor="#a0c0ff" cellspacing="0">
244
<th> <a
245
href="genshi-module.html">Home</a> </th>
248
<th> <a
249
href="module-tree.html">Trees</a> </th>
252
<th> <a
253
href="identifier-index.html">Indices</a> </th>
256
<th> <a
257
href="help.html">Help</a> </th>
259
<!-- Project homepage -->
260
<th class="navbar" align="right" width="100%">
261
<table border="0" cellpadding="0" cellspacing="0">
262
<tr><th class="navbar" align="center"
263
><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
267
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
269
<td align="left" class="footer">
270
Generated by Epydoc 3.0beta1 on Mon Apr 16 16:02:14 2007
272
<td align="right" class="footer">
273
<a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
278
<script type="text/javascript">
280
// Private objects are initially displayed (because if
281
// javascript is turned off then we want them to be
282
// visible); but by default, we want to hide them. So hide
283
// them unless we have a cookie that says to show them.