used the new nodetransformer to make mitsuhiko happy

--HG--
branch : trunk
diff --git a/jinja2/optimizer.py b/jinja2/optimizer.py
index b12b1f4..c9787f6 100644
--- a/jinja2/optimizer.py
+++ b/jinja2/optimizer.py
@@ -8,7 +8,7 @@
         * eliminating constant nodes
         * evaluating filters and macros on constant nodes
         * unroll loops on constant values
-        * replace variables which are already known (because the doesn't
+        * replace variables which are already known (because they doesn't
           change often and you want to prerender a template) with constants
 
     After the optimation you will get a new, simplier template which can
@@ -24,27 +24,12 @@
 from jinja2.visitor import NodeVisitor, NodeTransformer
 
 
-class Optimizer(NodeVisitor):
+class Optimizer(NodeTransformer):
 
     def __init__(self, environment, context={}):
         self.environment = environment
         self.context = context
 
-    def visit_Output(self, node):
-        node.nodes = [self.visit(n) for n in node.nodes]
-        return node
-
-    def visit_Template(self, node):
-        body = []
-        for n in node.body:
-            x = self.visit(n)
-            if isinstance(x, list):
-                body.extend(x)
-            else:
-                body.append(x)
-        node.body = body
-        return node
-
     def visit_Filter(self, node):
         """Try to evaluate filters if possible."""
         try:
@@ -77,10 +62,6 @@
             return node
         return nodes.Const(self.context[node.name])
 
-    def generic_visit(self, node, *args, **kwargs):
-        NodeVisitor.generic_visit(self, node, *args, **kwargs)
-        return node
-
 
 def optimize(node, environment):
     optimizer = Optimizer(environment)
diff --git a/test_optimizer.py b/test_optimizer.py
index 7320243..e23d862 100644
--- a/test_optimizer.py
+++ b/test_optimizer.py
@@ -8,8 +8,8 @@
     Hi {{ "<blub>"|e }},
     how are you?
 
-    {% for item in ('foo', 'bar', 'blub') %}
-        {{ item }}
+    {% for item in ('foo', 'bar', 'blub', '<42>') %}
+        {{ item|e }}
     {% endfor %}
 """)
 print ast