From 8bccba1a2fb5479ead0594b09dad95d4d22a5cec Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 25 Jun 2013 16:27:58 -0500 Subject: [PATCH] [feature/twig] INCLUDEPHP token, replace variable usage with $context I could find no better way to do this... PHPBB3-11598 --- phpBB/includes/template/twig/node/includephp.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/template/twig/node/includephp.php b/phpBB/includes/template/twig/node/includephp.php index 0f964556f0..6e77fac55d 100644 --- a/phpBB/includes/template/twig/node/includephp.php +++ b/phpBB/includes/template/twig/node/includephp.php @@ -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')) {