public function compile($compiler)
{
- static $i = 0;
-
$compiler
->addDebugInfo($this)
->pushContext()
$loopVars = array('_key', $this->item->getName());
}
- $var = $i++;
$compiler
- ->write("\$seq$var = twig_iterator_to_array(")
+ ->write("\$context['_seq'] = twig_iterator_to_array(")
->subcompile($this->seq)
->raw(");\n")
;
if ($this->withLoop)
{
$compiler
- ->write("\$length = count(\$seq$var);\n")
+ ->write("\$length = count(\$context['_seq']);\n")
->write("\$context['loop'] = array(\n")
->write(" 'parent' => \$context['_parent'],\n")
}
$compiler
- ->write("foreach (\$seq$var as \$context[")
+ ->write("foreach (\$context['_seq'] as \$context[")
->repr($loopVars[0])
->raw("] => \$context[")
->repr($loopVars[1])