Index: trunk/django/template/defaulttags.py
===================================================================
--- trunk/django/template/defaulttags.py	(revisão 4905)
+++ trunk/django/template/defaulttags.py	(cópia de trabalho)
@@ -355,20 +355,19 @@
         return str(int(round(ratio)))
 
 class WithNode(Node):
-    def __init__(self, var, name, nodelist):
-        self.var = var
-        self.name = name
+    def __init__(self, varlist, nodelist):
+        self.varlist = varlist
         self.nodelist = nodelist
 
     def __repr__(self):
         return "<WithNode>"
 
     def render(self, context):
-        val = self.var.resolve(context)
-        context.push()
-        context[self.name] = val
+        context.push() # start a new context
+        for var, name in self.varlist:
+            context[name] = var.resolve(context)
         output = self.nodelist.render(context)
-        context.pop()
+        context.pop() # delete the new context
         return output
 
 #@register.tag
@@ -988,19 +987,26 @@
 #@register.tag
 def do_with(parser, token):
     """
-    Add a value to the context (inside of this block) for caching and easy
+    Add values to the context (inside of this block) for caching and easy
     access. For example::
 
         {% with person.some_sql_method as total %}
             {{ total }} object{{ total|pluralize }}
         {% endwith %}
+        {% with person.some_sql_method as total and person.name as name %}
+            {{ name }}: {{ total }} object{{ total| pluralize }}
+        {% endwith %}
     """
     bits = list(token.split_contents())
-    if len(bits) != 4 or bits[2] != "as":
-        raise TemplateSyntaxError, "%r expected format is 'value as name'" % tagname
-    var = parser.compile_filter(bits[1])
-    name = bits[3]
+    bits.pop(0)
+    if not bits:
+        raise TemplateSyntaxError, "'with' expected format is 'value as name' or 'value1 as name1 and value2 as name2...'"
+    bitlist = [bitstr.split(' ') for bitstr in ' '.join(bits).split(' and ')]
+    try:
+        varlist = [(parser.compile_filter(var), name) for var, prep, name in bitlist]
+    except ValueError:
+        raise TemplateSyntaxError, "'with' expected format is 'value as name' or 'value1 as name1 and value2 as name2...'"
     nodelist = parser.parse(('endwith',))
     parser.delete_first_token()
-    return WithNode(var, name, nodelist)
+    return WithNode(varlist, nodelist)
 do_with = register.tag('with', do_with)
Index: trunk/tests/regressiontests/templates/tests.py
===================================================================
--- trunk/tests/regressiontests/templates/tests.py	(revisão 4905)
+++ trunk/tests/regressiontests/templates/tests.py	(cópia de trabalho)
@@ -653,6 +653,7 @@
             ### WITH TAG ########################################################
             'with01': ('{% with dict.key as key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, '50'),
             'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')),
+            'with03': ('{{ key1 }}{{ key2 }}{% with dict.key1 as key1 and dict.key2 as key2 %}{{ key1 }}{{ key 2 }}-{{ dict.key1 }}{{ dict.key2 }}-{{ key1 }}{{ key2 }}{% endwith %}{{ key1 }}{{ key2 }}', {'dict': {'key1':50, 'key2':60}}, ('5060-5060-5060', 'INVALIDINVALID5060-5060-5060INVALIDINVALID')),
 
             ### NOW TAG ########################################################
             # Simple case
Index: trunk/docs/templates.txt
===================================================================
--- trunk/docs/templates.txt	(revisão 4905)
+++ trunk/docs/templates.txt	(cópia de trabalho)
@@ -887,6 +887,12 @@
         {{ total }} employee{{ total|pluralize }}
     {% endwith %}
 
+Or even::
+
+    {% with business.name as name and business.employees.count as total %}
+        {{ name }}: employee{{ total|pluralize }}
+    {% endwith %}
+
 The populated variable (in the example above, ``total``) is only available
 between the ``{% with %}`` and ``{% endwith %}`` tags.
 
