Skip to content

Commit

Permalink
Fixed the indentation in the compiled template for the DumpNode
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed May 18, 2015
1 parent 991eec1 commit 9106ddb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Node/DumpNode.php
Expand Up @@ -79,6 +79,6 @@ public function compile(\Twig_Compiler $compiler)

$compiler
->outdent()
->raw("}\n");
->write("}\n");
}
}
24 changes: 24 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php
Expand Up @@ -39,6 +39,30 @@ public function testNoVar()
$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(
Expand Down

0 comments on commit 9106ddb

Please sign in to comment.