LightnCandy\Compiler::compileLookup PHP Method

compileLookup() protected static method

Return compiled PHP code for a handlebars lookup token
protected static compileLookup ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw, boolean $nosep = false ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$raw boolean is this {{{ token or not
$nosep boolean true to compile without seperator
return string Return compiled code segment for the token
    protected static function compileLookup(&$context, &$vars, $raw, $nosep = false)
    {
        $v2 = static::getVariableName($context, $vars[2]);
        $v = static::getVariableName($context, $vars[1], $v2);
        $sep = $nosep ? '' : $context['ops']['seperator'];
        if ($context['flags']['hbesc'] || $context['flags']['jsobj'] || $context['flags']['jstrue'] || $context['flags']['debug']) {
            return $sep . static::getFuncName($context, $raw ? 'raw' : $context['ops']['enc'], $v[1]) . "\$cx, {$v[0]}){$sep}";
        } else {
            return $raw ? "{$sep}{$v['0']}{$sep}" : "{$sep}htmlentities((string){$v[0]}, ENT_QUOTES, 'UTF-8'){$sep}";
        }
    }