{
public function __construct($name, $lineno, $tag = null)
{
- parent::__construct(array(), array('name' => $name), $lineno, $tag);
+ // hack to be BC
+ if ($name instanceof Twig_NodeInterface) {
+ parent::__construct(array('name' => $name), array(), $lineno, $tag);
+ } else {
+ parent::__construct(array(), array('name' => $name), $lineno, $tag);
+ }
}
/**
*/
public function compile(Twig_Compiler $compiler)
{
- $compiler
- ->addDebugInfo($this)
- ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
- ;
+ if ($this->hasNode('name')) {
+ $compiler
+ ->addDebugInfo($this)
+ ->raw("\$this->displayBlock(")
+ ->subcompile($this->getNode('name'))
+ ->write(", \$context, \$blocks);\n")
+ ;
+ } else {
+ $compiler
+ ->addDebugInfo($this)
+ ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
+ ;
+ }
}
}
protected function optimizeRenderBlock($node, $env)
{
if ($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_BlockReference) {
- $name = $node->getNode('expr')->getNode('name');
- if ($name instanceof Twig_Node_Expression_Constant) {
- return new Twig_Node_BlockReference($name->getAttribute('value'), $node->getLine(), $node->getNodeTag());
- } else {
- return new Twig_Node_BlockReference($name, $node->getLine(), $node->getNodeTag());
- }
+ return new Twig_Node_BlockReference($node->getNode('expr')->getNode('name'), $node->getLine(), $node->getNodeTag());
}
return $node;