Fixed the indentation in the compiled template for the DumpNode

This commit is contained in:
Christophe Coevoet 2015-05-18 19:20:21 +02:00
parent 991eec1e1e
commit 9106ddb779
2 changed files with 25 additions and 1 deletions

View File

@ -79,6 +79,6 @@ class DumpNode extends \Twig_Node
$compiler
->outdent()
->raw("}\n");
->write("}\n");
}
}

View File

@ -39,6 +39,30 @@ EOTXT;
$this->assertSame($expected, $compiler->compile($node)->getSource());
}
public function testIndented()
{
$node = new DumpNode('bar', null, 7);
$env = new \Twig_Environment();
$compiler = new \Twig_Compiler($env);
$expected = <<<'EOTXT'
if ($this->env->isDebug()) {
$barvars = array();
foreach ($context as $barkey => $barval) {
if (!$barval instanceof \Twig_Template) {
$barvars[$barkey] = $barval;
}
}
// line 7
\Symfony\Component\VarDumper\VarDumper::dump($barvars);
}
EOTXT;
$this->assertSame($expected, $compiler->compile($node, 1)->getSource());
}
public function testOneVar()
{
$vars = new \Twig_Node(array(