comparison doc/builder.txt @ 230:24757b771651

Renamed Markup to Genshi in repository.
author cmlenz
date Mon, 11 Sep 2006 15:07:07 +0000
parents 09f869a98149
children b3cabd49de75
comparison
equal deleted inserted replaced
229:110d69dbbda3 230:24757b771651
2 2
3 ================================== 3 ==================================
4 Generating Markup Programmatically 4 Generating Markup Programmatically
5 ================================== 5 ==================================
6 6
7 Markup provides a ``builder`` module which lets you generate markup from Python 7 Genshi provides a ``builder`` module which lets you generate markup from Python
8 code using a very simple syntax. The main entry point to the ``builder`` module 8 code using a very simple syntax. The main entry point to the ``builder`` module
9 is the ``tag`` object (which is actually an instance of the ``ElementFactory`` 9 is the ``tag`` object (which is actually an instance of the ``ElementFactory``
10 class). You should rarely (if ever) need to directly import and use any of the 10 class). You should rarely (if ever) need to directly import and use any of the
11 other classes in the ``builder`` module. 11 other classes in the ``builder`` module.
12 12
20 ================= 20 =================
21 21
22 Elements can be created through the `tag` object using attribute access, for 22 Elements can be created through the `tag` object using attribute access, for
23 example:: 23 example::
24 24
25 >>> from markup.builder import tag 25 >>> from genshi.builder import tag
26 >>> doc = tag.p('Some text and ', tag.a('a link', href='http://example.org/'), '.') 26 >>> doc = tag.p('Some text and ', tag.a('a link', href='http://example.org/'), '.')
27 >>> doc 27 >>> doc
28 <Element "p"> 28 <Element "p">
29 29
30 This produces an ``Element`` instance which can be further modified to add child 30 This produces an ``Element`` instance which can be further modified to add child
50 shortcut for converting the ``Element`` to a stream and serializing that 50 shortcut for converting the ``Element`` to a stream and serializing that
51 stream:: 51 stream::
52 52
53 >>> stream = doc.generate() 53 >>> stream = doc.generate()
54 >>> stream 54 >>> stream
55 <markup.core.Stream object at 0x72d230> 55 <genshi.core.Stream object at 0x72d230>
56 >>> print stream 56 >>> print stream
57 <p class="intro">Some text and <a href="http://example.org/">a link</a>.<br/></p> 57 <p class="intro">Some text and <a href="http://example.org/">a link</a>.<br/></p>
58 58
59 59
60 Creating Fragments 60 Creating Fragments
Copyright (C) 2012-2017 Edgewall Software