# HG changeset patch # User cmlenz # Date 1154505811 0 # Node ID cc2aee07f53b5984c0517633ee261ef89a4beb00 # Parent c392d38694d9040c2c56ede69d310c276e6f2f4c Allow creating fragments from the `tag` object in `markup.builder`. diff --git a/markup/builder.py b/markup/builder.py --- a/markup/builder.py +++ b/markup/builder.py @@ -204,6 +204,12 @@ >>> print factory.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, world! + 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)