mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-28 19:17:37 +00:00
rework the CaptureNode implementation
This commit is contained in:
committed by
Fabien Potencier
parent
3f70efae53
commit
665dce899f
@@ -57,7 +57,7 @@ class CaptureNode extends Node
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
->outdent()
|
||||
->write('})()')
|
||||
->write('})();')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ class MacroNode extends Node
|
||||
}
|
||||
}
|
||||
|
||||
$body = new CaptureNode($body, $lineno, $tag);
|
||||
|
||||
parent::__construct(['body' => $body, 'arguments' => $arguments], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
@@ -88,8 +86,8 @@ class MacroNode extends Node
|
||||
->write("]);\n\n")
|
||||
->write("\$blocks = [];\n\n")
|
||||
->write('return ')
|
||||
->subcompile($this->getNode('body'))
|
||||
->raw(";\n")
|
||||
->subcompile(new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag))
|
||||
->raw("\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
;
|
||||
|
||||
@@ -86,8 +86,10 @@ class SetNode extends Node implements NodeCaptureInterface
|
||||
$compiler->subcompile($this->getNode('values'));
|
||||
}
|
||||
}
|
||||
|
||||
$compiler->raw(';');
|
||||
}
|
||||
|
||||
$compiler->raw(";\n");
|
||||
$compiler->raw("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class MacroTest extends NodeTestCase
|
||||
$arguments = new Node([new NameExpression('foo', 1)], [], 1);
|
||||
$node = new MacroNode('foo', $body, $arguments, 1);
|
||||
|
||||
$this->assertEquals($body, $node->getNode('body')->getNode('body'));
|
||||
$this->assertEquals($body, $node->getNode('body'));
|
||||
$this->assertEquals($arguments, $node->getNode('arguments'));
|
||||
$this->assertEquals('foo', $node->getAttribute('name'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user