core\Template::parseLoop PHP Method

parseLoop() public static method

public static parseLoop ( $match )
    public static function parseLoop($match)
    {
        $variable = self::pregGet($match[1], '/variable="([^"]+)"/i');
        if (!$variable) {
            $variable = self::pregGet($match[1], '/^\\s*"([^"]+)"/i');
        }
        if (!$variable) {
            throw new Error('Cannot convert loop label: ' . htmlspecialchars($match[0]), 102);
        }
        $query = self::pregGet($match[1], '/query="([^"]+)"/i');
        if ($query) {
            return '<?php while (' . $variable . ' = ' . $query . '->getRow()) { ?>';
        }
        $key = self::pregGet($match[1], '/key="([^"]+)"/i');
        $value = self::pregGet($match[1], '/value="([^"]+)"/i');
        return '<?php foreach (' . $variable . ' as ' . ($key ? $key : '$key') . ' => ' . ($value ? $value : '$value') . ') { ?>';
    }