protected function compileDisplayBody(Twig_Compiler $compiler)
{
- $compiler->write("\$context = array_merge(\$this->env->getGlobals(), \$context);\n\n");
$compiler->subcompile($this->getNode('body'));
if (null !== $this->getNode('parent')) {
*/
public function display(array $context, array $blocks = array())
{
+ // we don't use array_merge as the context being generally
+ // bigger than globals, this code is faster.
+ foreach ($this->env->getGlobals() as $key => $value) {
+ if (!array_key_exists($key, $context)) {
+ $context[$key] = $value;
+ }
+ }
+
try {
$this->doDisplay($context, $blocks);
} catch (Twig_Error $e) {
protected function doDisplay(array \$context, array \$blocks = array())
{
- \$context = array_merge(\$this->env->getGlobals(), \$context);
-
echo "foo";
}
protected function doDisplay(array \$context, array \$blocks = array())
{
- \$context = array_merge(\$this->env->getGlobals(), \$context);
-
\$context["macro"] = \$this->env->loadTemplate("foo.twig");
\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
}
protected function doDisplay(array \$context, array \$blocks = array())
{
- \$context = array_merge(\$this->env->getGlobals(), \$context);
-
\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
}
protected function doDisplay(array \$context, array \$blocks = array())
{
\$this->checkSecurity();
- \$context = array_merge(\$this->env->getGlobals(), \$context);
-
echo "foo";
}
protected function doDisplay(array \$context, array \$blocks = array())
{
- \$context = array_merge(\$this->env->getGlobals(), \$context);
-
\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
}