Skip to content

Commit 9106ddb

Browse files
committed
Fixed the indentation in the compiled template for the DumpNode
1 parent 991eec1 commit 9106ddb

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Symfony/Bridge/Twig/Node/DumpNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ public function compile(\Twig_Compiler $compiler)
7979

8080
$compiler
8181
->outdent()
82-
->raw("}\n");
82+
->write("}\n");
8383
}
8484
}

src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ public function testNoVar()
3939
$this->assertSame($expected, $compiler->compile($node)->getSource());
4040
}
4141

42+
public function testIndented()
43+
{
44+
$node = new DumpNode('bar', null, 7);
45+
46+
$env = new \Twig_Environment();
47+
$compiler = new \Twig_Compiler($env);
48+
49+
$expected = <<<'EOTXT'
50+
if ($this->env->isDebug()) {
51+
$barvars = array();
52+
foreach ($context as $barkey => $barval) {
53+
if (!$barval instanceof \Twig_Template) {
54+
$barvars[$barkey] = $barval;
55+
}
56+
}
57+
// line 7
58+
\Symfony\Component\VarDumper\VarDumper::dump($barvars);
59+
}
60+
61+
EOTXT;
62+
63+
$this->assertSame($expected, $compiler->compile($node, 1)->getSource());
64+
}
65+
4266
public function testOneVar()
4367
{
4468
$vars = new \Twig_Node(array(

0 commit comments

Comments
 (0)