# HG changeset patch
# User cmlenz
# Date 1154505811 0
# Node ID 61b133ed95b232aa8d49987419249b1b74e4aab7
# Parent 226613431921df9fe30972609dcc72fd0e013d66
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)