mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 05:16:30 +00:00
Remove obsolete code about non-yield templates
This commit is contained in:
+5
-13
@@ -151,14 +151,14 @@ final class ModuleNode extends Node
|
||||
->write("use Twig\Sandbox\SecurityNotAllowedFilterError;\n")
|
||||
->write("use Twig\Sandbox\SecurityNotAllowedFunctionError;\n")
|
||||
->write("use Twig\Source;\n")
|
||||
->write(sprintf("use Twig\%s;\n\n", $compiler->getEnvironment()->useYield() ? 'YieldingTemplate' : 'Template'))
|
||||
->write("use Twig\YieldingTemplate;\n\n")
|
||||
;
|
||||
}
|
||||
$compiler
|
||||
// if the template name contains */, add a blank to avoid a PHP parse error
|
||||
->write('/* '.str_replace('*/', '* /', $this->getSourceContext()->getName())." */\n")
|
||||
->write('class '.$compiler->getEnvironment()->getTemplateClass($this->getSourceContext()->getName(), $this->getAttribute('index')))
|
||||
->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->useYield() ? 'YieldingTemplate' : 'Template'))
|
||||
->raw(" extends YieldingTemplate\n")
|
||||
->write("{\n")
|
||||
->indent()
|
||||
->write("private Source \$source;\n")
|
||||
@@ -326,23 +326,15 @@ final class ModuleNode extends Node
|
||||
->raw(");\n")
|
||||
;
|
||||
}
|
||||
if ($compiler->getEnvironment()->useYield()) {
|
||||
$compiler->write('yield from ');
|
||||
} else {
|
||||
$compiler->write('');
|
||||
}
|
||||
$compiler->write('yield from ');
|
||||
|
||||
if ($parent instanceof ConstantExpression) {
|
||||
$compiler->raw('$this->parent');
|
||||
} else {
|
||||
$compiler->raw('$this->getParent($context)');
|
||||
}
|
||||
if ($compiler->getEnvironment()->useYield()) {
|
||||
$compiler->raw("->unwrap()->yield(\$context, array_merge(\$this->blocks, \$blocks));\n");
|
||||
} else {
|
||||
$compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
|
||||
}
|
||||
} elseif ($compiler->getEnvironment()->useYield() && !$this->hasNodeOutputNodes($this->getNode('body'))) {
|
||||
$compiler->raw("->unwrap()->yield(\$context, array_merge(\$this->blocks, \$blocks));\n");
|
||||
} elseif (!$this->hasNodeOutputNodes($this->getNode('body'))) {
|
||||
// ensure at least one yield call even for templates with no output
|
||||
$compiler->write("yield '';\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user