Habari\HiEngineParser::hi_loop PHP Метод

hi_loop() публичный Метод

Replace a loop tag section with its PHP counterpart, and add the context to the stack
public hi_loop ( array $matches ) : string
$matches array The match array found in HiEngineParser::process()
Результат string The PHP replacement for the template tag
    function hi_loop($matches)
    {
        $hivar = $matches[1];
        $phpvar = $this->hi_to_var($hivar);
        $iterator = strpos($hivar, '.') ? substr($hivar, strrpos($hivar, '.') + 1) : $hivar;
        $output = '<?php foreach(' . $phpvar . ' as $' . $iterator . '_index => $' . $iterator . '_1): ?>';
        $this->contexts[] = "{$iterator}_1";
        $output .= $this->process($matches[2]);
        $output .= '<?php endforeach; ?>';
        array_pop($this->contexts);
        return $output;
    }