|
@@ -18,9 +18,9 @@ namespace Symfony\Bundle\TwigBundle\Node;
|
|
|
*/
|
|
|
class IncludeNode extends \Twig_Node
|
|
|
{
|
|
|
- public function __construct(\Twig_Node_Expression $expr, \Twig_Node_Expression $variables = null, $lineno, $tag = null)
|
|
|
+ public function __construct(\Twig_Node_Expression $expr, \Twig_Node_Expression $variables = null, $only = false, $lineno, $tag = null)
|
|
|
{
|
|
|
- parent::__construct(array('expr' => $expr, 'variables' => $variables), array(), $lineno, $tag);
|
|
|
+ parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (Boolean) $only), $lineno, $tag);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -37,10 +37,22 @@ class IncludeNode extends \Twig_Node
|
|
|
->raw(', ')
|
|
|
;
|
|
|
|
|
|
- if (null === $this->getNode('variables')) {
|
|
|
- $compiler->raw('$context');
|
|
|
+ if (false === $this->getAttribute('only')) {
|
|
|
+ if (null === $this->getNode('variables')) {
|
|
|
+ $compiler->raw('$context');
|
|
|
+ } else {
|
|
|
+ $compiler
|
|
|
+ ->raw('array_merge($context, ')
|
|
|
+ ->subcompile($this->getNode('variables'))
|
|
|
+ ->raw(')')
|
|
|
+ ;
|
|
|
+ }
|
|
|
} else {
|
|
|
- $compiler->subcompile($this->getNode('variables'));
|
|
|
+ if (null === $this->getNode('variables')) {
|
|
|
+ $compiler->raw('array()');
|
|
|
+ } else {
|
|
|
+ $compiler->subcompile($this->getNode('variables'));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$compiler->raw(");\n");
|