Changes between Version 4 and Version 5 of MarkupBuilder
- Timestamp:
- Aug 2, 2006, 10:19:42 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MarkupBuilder
v4 v5 1 1 = Generating Markup Programmatically = 2 2 3 Markup provides a [wiki:ApiDocs/MarkupBuilder builder] module which lets you generate markup from Python code using a very simple syntax. 3 Markup provides a [wiki:ApiDocs/MarkupBuilder builder] module which lets you generate markup from Python code using a very simple syntax. The main entry point to the `builder` module is the `tag` object (which is actually an instance of the `ElementFactory` class). You should rarely (if ever) need to directly import and use any of the other classes in the `markup.builder` module. 4 4 5 The main entry point to the `builder` module is the `tag` object (which is actually an instance of the `ElementFactory` class). Elements can be created through this `tag` object using attribute access, for example: 5 == Creating Elements == 6 7 Elements can be created through the `tag` object using attribute access, for example: 6 8 7 9 {{{ … … 40 42 }}} 41 43 44 == Creating Markup Fragments == 45 46 The `tag` object also allows creating “fragments”, which are basically lists of nodes (elements or text) that don't have a parent element. This can be useful for creating snippets of markup that are attached to a parent element later (for example in a template). Fragments are created by calling the `tag` object: 47 48 {{{ 49 >>> fragment = tag('Hello, ', tag.em('word'), '!') 50 >>> fragment 51 <Fragment> 52 >>> print fragment 53 Hello, <em>world</em>! 54 }}} 55 42 56 ---- 43 57 See also: MarkupGuide, MarkupStream