fixed node visiting for macros (macros are now visited by visitors as any other node)
authorFabien Potencier <fabien.potencier@gmail.com>
Thu, 6 May 2010 06:34:23 +0000 (08:34 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Thu, 6 May 2010 06:35:36 +0000 (08:35 +0200)
lib/Twig/Node/Module.php

index d22a990..7d0e555 100644 (file)
@@ -86,13 +86,25 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface
 
   public function getNodes()
   {
-    return array_merge(array($this->body), $this->blocks);
+    return array_merge(array($this->body), $this->blocks, $this->macros);
   }
 
   public function setNodes(array $nodes)
   {
     $this->body   = array_shift($nodes);
-    $this->blocks = $nodes;
+    $this->blocks = array();
+    $this->macros = array();
+    foreach ($nodes as $node)
+    {
+      if ($node instanceof Twig_Node_Macro)
+      {
+        $this->macros[] = $node;
+      }
+      else
+      {
+        $this->blocks[] = $node;
+      }
+    }
   }
 
   public function setUsedFilters(array $filters)