protected function Twig_NodeVisitor_Optimizer::optimizePrintNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php \Twig_NodeVisitor_Optimizer::optimizePrintNode()
Optimizes print nodes.
It replaces:
- "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()"
Parameters
Twig_NodeInterface $node A Node:
Twig_Environment $env The current Twig environment:
Return value
1 call to Twig_NodeVisitor_Optimizer::optimizePrintNode()
- Twig_NodeVisitor_Optimizer::doLeaveNode in vendor/
twig/ twig/ lib/ Twig/ NodeVisitor/ Optimizer.php - Called after child nodes are visited.
File
- vendor/
twig/ twig/ lib/ Twig/ NodeVisitor/ Optimizer.php, line 135
Class
- Twig_NodeVisitor_Optimizer
- Twig_NodeVisitor_Optimizer tries to optimizes the AST.
Code
protected function optimizePrintNode(Twig_NodeInterface $node, Twig_Environment $env) {
if (!$node instanceof Twig_Node_Print) {
return $node;
}
if ($node
->getNode('expr') instanceof Twig_Node_Expression_BlockReference || $node
->getNode('expr') instanceof Twig_Node_Expression_Parent) {
$node
->getNode('expr')
->setAttribute('output', true);
return $node
->getNode('expr');
}
return $node;
}