LightnCandy\Compiler::section PHP Méthode

section() protected static méthode

compile {{#foo}} token
protected static section ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $isEach = false ) : string | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$isEach boolean the section is #each
Résultat string | null Return compiled code segment for the token
    protected static function section(&$context, $vars, $isEach = false)
    {
        $bs = 'null';
        $be = '';
        if ($isEach) {
            $bp = Parser::getBlockParams($vars);
            $bs = $bp ? 'array(' . Expression::listString($bp) . ')' : 'null';
            $be = $bp ? " as |{$bp['0']} {$bp['1']}|" : '';
            array_shift($vars);
        }
        if ($context['flags']['lambda'] && !$isEach) {
            $V = array_shift($vars);
            $v = static::getVariableName($context, $V, null, count($vars) ? static::getVariableNames($context, $vars) : array('0', array('')));
        } else {
            $v = static::getVariableNameOrSubExpression($context, $vars[0]);
        }
        $each = $isEach ? 'true' : 'false';
        return $context['ops']['seperator'] . static::getFuncName($context, 'sec', ($isEach ? 'each ' : '') . $v[1] . $be) . "\$cx, {$v[0]}, {$bs}, \$in, {$each}, function(\$cx, \$in) {{$context['ops']['f_start']}";
    }