Index: django/template/defaulttags.py
===================================================================
--- django/template/defaulttags.py	(revision 8969)
+++ django/template/defaulttags.py	(working copy)
@@ -1123,12 +1123,13 @@
             {{ total }} object{{ total|pluralize }}
         {% endwith %}
     """
-    bits = list(token.split_contents())
-    if len(bits) != 4 or bits[2] != "as":
+    bits = list(token.contents.split())
+    if bits[-2] != "as":
         raise TemplateSyntaxError("%r expected format is 'value as name'" %
                                   bits[0])
-    var = parser.compile_filter(bits[1])
-    name = bits[3]
+    
+    var = parser.compile_filter(' '.join(bits[1:-2]))
+    name = bits[-1]
     nodelist = parser.parse(('endwith',))
     parser.delete_first_token()
     return WithNode(var, name, nodelist)
Index: tests/regressiontests/templates/tests.py
===================================================================
--- tests/regressiontests/templates/tests.py	(revision 8969)
+++ tests/regressiontests/templates/tests.py	(working copy)
@@ -877,7 +877,8 @@
             ### 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': ('{% with input|cut:" " as cutted %}{{ cutted }}{% endwith %}', {'input': 'string with spaces'}, 'stringwithspaces'),
+            
             'with-error01': ('{% with dict.key xx key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError),
             'with-error02': ('{% with dict.key as %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError),
 
