mirror of
https://github.com/twigphp/Twig.git
synced 2026-11-04 10:05:03 +00:00
Expose the escaping strategy a template was compiled with
This commit is contained in:
@@ -73,6 +73,7 @@ final class ModuleNode extends Node implements CoercesChildrenToStringInterface
|
||||
parent::__construct($nodes, [
|
||||
'index' => null,
|
||||
'embedded_templates' => $embeddedTemplates,
|
||||
'strategy' => false,
|
||||
], 1);
|
||||
|
||||
// populate the template name of all node children
|
||||
@@ -121,6 +122,8 @@ final class ModuleNode extends Node implements CoercesChildrenToStringInterface
|
||||
|
||||
$this->compileIsTraitable($compiler);
|
||||
|
||||
$this->compileGetDefaultEscapeStrategy($compiler);
|
||||
|
||||
$this->compileDebugInfo($compiler);
|
||||
|
||||
$this->compileGetSourceContext($compiler);
|
||||
@@ -462,6 +465,26 @@ final class ModuleNode extends Node implements CoercesChildrenToStringInterface
|
||||
;
|
||||
}
|
||||
|
||||
protected function compileGetDefaultEscapeStrategy(Compiler $compiler): void
|
||||
{
|
||||
if (false === $strategy = $this->getAttribute('strategy')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$compiler
|
||||
->write("/**\n")
|
||||
->write(" * @codeCoverageIgnore\n")
|
||||
->write(" */\n")
|
||||
->write("public function getDefaultEscapeStrategy(): string|false\n", "{\n")
|
||||
->indent()
|
||||
->write('return ')
|
||||
->repr($strategy)
|
||||
->raw(";\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
;
|
||||
}
|
||||
|
||||
protected function compileDebugInfo(Compiler $compiler): void
|
||||
{
|
||||
$compiler
|
||||
|
||||
Reference in New Issue
Block a user