22 if (null !== $variables) {
23 $nodes[
'variables'] = $variables;
33 if ($this->
hasNode(
'variables')) {
36 ->
write(sprintf(
'$%s = ', $varsName))
37 ->subcompile($this->
getNode(
'variables'))
39 ->write(sprintf(
"if (!is_array(\$%s)) {\n", $varsName))
41 ->write(
"throw new Twig_Error_Runtime('Variables passed to the \"with\" tag must be a hash.');\n")
47 $compiler->
write(
"\$context = array('_parent' => \$context);\n");
49 $compiler->
write(
"\$context['_parent'] = \$context;\n");
52 $compiler->
write(sprintf(
"\$context = array_merge(\$context, \$%s);\n", $varsName));
54 $compiler->
write(
"\$context['_parent'] = \$context;\n");
59 ->write(
"\$context = \$context['_parent'];\n")
64 class_alias(
'Twig_Node_With',
'Twig\Node\WithNode',
false);
subcompile(Twig_NodeInterface $node, $raw=true)
Represents a node in the AST.
__construct(Twig_Node $body, Twig_Node $variables=null, $only=false, $lineno, $tag=null)
Create styles array
The data for the language used.
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
Represents a nested "with" scope.
write()
Writes a string to the compiled code by adding indentation.