LightnCandy\Compiler::doElse PHP Method

doElse() protected static method

Return compiled PHP code for a handlebars else token
protected static doElse ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
return string Return compiled code segment for the token when the token is else
    protected static function doElse(&$context, $vars)
    {
        $v = $context['stack'][count($context['stack']) - 2];
        if ($v === '[if]' && !isset($context['helpers']['if']) || $v === '[unless]' && !isset($context['helpers']['unless'])) {
            $context['stack'][] = ':';
            return "{$context['ops']['cnd_else']}";
        }
        return "{$context['ops']['f_end']}}, function(\$cx, \$in) {{$context['ops']['f_start']}";
    }