mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 20:36:33 +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()
|
->outdent()
|
||||||
->write("}\n")
|
->write("}\n")
|
||||||
->outdent()
|
->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);
|
parent::__construct(['body' => $body, 'arguments' => $arguments], ['name' => $name], $lineno, $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +86,8 @@ class MacroNode extends Node
|
|||||||
->write("]);\n\n")
|
->write("]);\n\n")
|
||||||
->write("\$blocks = [];\n\n")
|
->write("\$blocks = [];\n\n")
|
||||||
->write('return ')
|
->write('return ')
|
||||||
->subcompile($this->getNode('body'))
|
->subcompile(new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag))
|
||||||
->raw(";\n")
|
->raw("\n")
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("}\n\n")
|
->write("}\n\n")
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -86,8 +86,10 @@ class SetNode extends Node implements NodeCaptureInterface
|
|||||||
$compiler->subcompile($this->getNode('values'));
|
$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);
|
$arguments = new Node([new NameExpression('foo', 1)], [], 1);
|
||||||
$node = new MacroNode('foo', $body, $arguments, 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($arguments, $node->getNode('arguments'));
|
||||||
$this->assertEquals('foo', $node->getAttribute('name'));
|
$this->assertEquals('foo', $node->getAttribute('name'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user