src/Leevel/View/Compiler.php
public function forJsCompiler(array &$theme): void
    {
        $this->checkNode($theme, true);
        $attr = $this->getNodeAttribute($theme);
        $attr = array_values($attr);

        if (!in_array('in', $attr, true)) {
            throw new InvalidArgumentException('For tag need “in“ separate.');
        }

        $key = 'key';
        $value = array_shift($attr);

        if (false !== strpos($value, ',')) {
            list($key, $value) = explode(',', $value);
        }

        $next = array_shift($attr);

        if ('in' !== $next) {
            $key = $value;
            $value = $next;
            array_shift($attr);
        }

        $attr = $this->parseExpression(implode(' ', $attr));

        $theme['content'] = $this->withPhpTag("foreach ({$attr} as \${$key} => \${$value}):");
        $theme['content'] .= $this->getNodeBody($theme);
        $theme['content'] .= $this->withPhpTag('endforeach;');
    }
public function forJsCompiler(array &$theme): void
    {
        $this->checkNode($theme, true);
        $attr = $this->getNodeAttribute($theme);
        $attr = array_values($attr);

        if (!in_array('in', $attr, true)) {
            throw new InvalidArgumentException('For tag need “in“ separate.');
        }

        $key = 'key';
        $value = array_shift($attr);

        if (false !== strpos($value, ',')) {
            list($key, $value) = explode(',', $value);
        }

        $next = array_shift($attr);

        if ('in' !== $next) {
            $key = $value;
            $value = $next;
            array_shift($attr);
        }

        $attr = $this->parseExpression(implode(' ', $attr));

        $theme['content'] = $this->withPhpTag("foreach ({$attr} as \${$key} => \${$value}):");
        $theme['content'] .= $this->getNodeBody($theme);
        $theme['content'] .= $this->withPhpTag('endforeach;');
    }
for 循环.

@param array $theme