Commits

Anonymous committed 04052cd

Fixed #341.

  • Participants
  • Parent commits 08ecde4

Comments (0)

Files changed (2)

File tests/test_templates.py

     :license: BSD license.
 """
 from py.test import raises
+from werkzeug.utils import MultiDict
 from werkzeug.templates import Template
 
 
 def test_nl_trimp():
     t = Template('<% if 1 %>1<% endif %>\n2')
     assert t.render() == '12'
+
+
+def test_multidict():
+    t = Template('$a|$b')
+    assert t.render(MultiDict(dict(
+        a=[1, 2],
+        b=2
+    ))) == '1|2'

File werkzeug/templates.py

         value will be the rendered template.
         """
         ns = self.default_context.copy()
-        ns.update(dict(*args, **kwargs))
+        if len(args) == 1 and isinstance(args[0], utils.MultiDict):
+            ns.update(args[0].to_dict(flat=True))
+        else:
+            ns.update(dict(*args))
+        if kwargs:
+            ns.update(kwargs)
         context = Context(ns, self.encoding, self.errors)
         if sys.version_info < (2, 4):
             exec self.code in context.runtime, ns