~jtaylor/ubuntu/oneiric/genshi/dh_python2

« back to all changes in this revision

Viewing changes to doc/api/genshi.builder-module.html

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-05-05 02:05:51 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100505020551-zmiep9cjs3s5c093
Tags: 0.6-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/rules: Enable testsuite.
  - Update maintainer according to specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
<pre class="py-doctest">
75
75
<span class="py-prompt">&gt;&gt;&gt; </span>doc(tag.br)
76
76
<span class="py-output">&lt;Element &quot;p&quot;&gt;</span>
77
 
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> doc
 
77
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(doc)
78
78
<span class="py-output">&lt;p&gt;Some text and &lt;a href=&quot;http://example.org/&quot;&gt;a link&lt;/a&gt;.&lt;br/&gt;&lt;/p&gt;</span></pre>
79
79
<p>If an attribute name collides with a Python keyword, simply append an underscore
80
80
to the name:</p>
81
81
<pre class="py-doctest">
82
82
<span class="py-prompt">&gt;&gt;&gt; </span>doc(class_=<span class="py-string">'intro'</span>)
83
83
<span class="py-output">&lt;Element &quot;p&quot;&gt;</span>
84
 
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> doc
 
84
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(doc)
85
85
<span class="py-output">&lt;p class=&quot;intro&quot;&gt;Some text and &lt;a href=&quot;http://example.org/&quot;&gt;a link&lt;/a&gt;.&lt;br/&gt;&lt;/p&gt;</span></pre>
86
86
<p>As shown above, an <a href="genshi.builder.Element-class.html" class="link">Element</a> can easily be directly rendered to XML text by
87
87
printing it or using the Python <tt class="rst-docutils literal"><span class="pre">str()</span></tt> function. This is basically a
91
91
<span class="py-prompt">&gt;&gt;&gt; </span>stream = doc.generate()
92
92
<span class="py-prompt">&gt;&gt;&gt; </span>stream <span class="py-comment">#doctest: +ELLIPSIS</span>
93
93
<span class="py-output">&lt;genshi.core.Stream object at ...&gt;</span>
94
 
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> stream
 
94
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(stream)
95
95
<span class="py-output">&lt;p class=&quot;intro&quot;&gt;Some text and &lt;a href=&quot;http://example.org/&quot;&gt;a link&lt;/a&gt;.&lt;br/&gt;&lt;/p&gt;</span></pre>
96
96
<p>The <a href="genshi.builder-module.html#tag" class="link">tag</a> object also allows creating &quot;fragments&quot;, which are basically lists
97
97
of nodes (elements or text) that don't have a parent element. This can be useful
102
102
<span class="py-prompt">&gt;&gt;&gt; </span>fragment = tag(<span class="py-string">'Hello, '</span>, tag.em(<span class="py-string">'world'</span>), <span class="py-string">'!'</span>)
103
103
<span class="py-prompt">&gt;&gt;&gt; </span>fragment
104
104
<span class="py-output">&lt;Fragment&gt;</span>
105
 
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> fragment
 
105
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(fragment)
106
106
<span class="py-output">Hello, &lt;em&gt;world&lt;/em&gt;!</span></pre>
107
107
 
108
108
<!-- ==================== CLASSES ==================== -->
187
187
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
188
188
  <tr>
189
189
    <td align="left" class="footer">
190
 
    Generated by Epydoc 3.0.1 on Wed Jul  9 18:16:20 2008
 
190
    Generated by Epydoc 3.0.1 on Thu Apr 22 14:10:35 2010
191
191
    </td>
192
192
    <td align="right" class="footer">
193
193
      <a target="mainFrame" href="http://epydoc.sourceforge.net"