From: fabien Date: Sun, 13 Dec 2009 12:22:53 +0000 (+0000) Subject: added __toString() to Node_If X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=e4afc9fd7b14eaa6fe4d52998ffee570f688035b;p=web%2Fkonrad%2Ftwig.git added __toString() to Node_If git-svn-id: http://svn.twig-project.org/trunk@163 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- diff --git a/lib/Twig/Node/If.php b/lib/Twig/Node/If.php index 4cb6869..6763ee7 100644 --- a/lib/Twig/Node/If.php +++ b/lib/Twig/Node/If.php @@ -29,6 +29,29 @@ class Twig_Node_If extends Twig_Node implements Twig_NodeListInterface $this->else = $else; } + public function __toString() + { + $repr = array(get_class($this).'('); + foreach ($this->tests as $test) + { + foreach (explode("\n", $test[0].' => '.$test[1]) as $line) + { + $repr[] = ' '.$line; + } + } + $repr[] = ')'; + + if ($this->else) + { + foreach (explode("\n", $this->else) as $line) + { + $repr[] = ' '.$line; + } + } + + return implode("\n", $repr); + } + public function getNodes() { $nodes = array();