mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 21:38:54 +00:00
[feature/twig] INCLUDEPHP token, replace variable usage with $context
I could find no better way to do this... PHPBB3-11598
This commit is contained in:
parent
e227f05e9a
commit
8bccba1a2f
1 changed files with 6 additions and 3 deletions
|
@ -46,10 +46,13 @@ class phpbb_template_twig_node_includephp extends Twig_Node
|
|||
;
|
||||
}
|
||||
|
||||
// Replace variables in the expression
|
||||
$expr = preg_replace('#{{ ([a-zA-Z0-9_]+) }}#', '\' . ((isset($context["$1"])) ? $context["$1"] : null) . \'', $this->getNode('expr')->getAttribute('value'));
|
||||
|
||||
$compiler
|
||||
->write("include(\$this->getEnvironment()->get_phpbb_root_path() . ")
|
||||
->subcompile($this->getNode('expr'), true)
|
||||
->raw(");\n")
|
||||
->write("require(\$this->getEnvironment()->get_phpbb_root_path() . '")
|
||||
->raw($expr)
|
||||
->raw("');\n")
|
||||
;
|
||||
|
||||
if ($this->getAttribute('ignore_missing')) {
|
||||
|
|
Loading…
Add table
Reference in a new issue