Edgewall Software

Changes between Version 4 and Version 5 of MarkupBuilder


Ignore:
Timestamp:
Aug 2, 2006, 10:19:42 AM (18 years ago)
Author:
cmlenz
Comment:

Document fragment creation

Legend:

Unmodified
Added
Removed
Modified
  • MarkupBuilder

    v4 v5  
    11= Generating Markup Programmatically =
    22
    3 Markup provides a [wiki:ApiDocs/MarkupBuilder builder] module which lets you generate markup from Python code using a very simple syntax.
     3Markup 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.
    44
    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
     7Elements can be created through the `tag` object using attribute access, for example:
    68
    79{{{
     
    4042}}}
    4143
     44== Creating Markup Fragments ==
     45
     46The `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
     53Hello, <em>world</em>!
     54}}}
     55
    4256----
    4357See also: MarkupGuide, MarkupStream