Mercurial > genshi > genshi-test
changeset 119:61b133ed95b2
Allow creating fragments from the `tag` object in `markup.builder`.
author | cmlenz |
---|---|
date | Wed, 02 Aug 2006 08:03:31 +0000 |
parents | 226613431921 |
children | eb6cead67474 |
files | markup/builder.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/markup/builder.py +++ b/markup/builder.py @@ -204,6 +204,12 @@ >>> print factory.foo(id=2) <foo id="2"/> + Markup fragments (lists of nodes without a parent element) can be created + by calling the factory: + + >>> print factory('Hello, ', factory.em('world'), '!') + Hello, <em>world</em>! + A factory can also be bound to a specific namespace: >>> factory = ElementFactory('http://www.w3.org/1999/xhtml') @@ -231,6 +237,9 @@ namespace = Namespace(namespace) self.namespace = namespace + def __call__(self, *args): + return Fragment()(*args) + def __getitem__(self, namespace): """Return a new factory that is bound to the specified namespace.""" return ElementFactory(namespace)