public function parse(array $tokenStruct)
    {
        if (! $tokenStruct[0] === Lexer::TOKEN_VARIABLE) {
            return $tokenStruct;
        }

        $data = $tokenStruct[1];
        if (! preg_match('/^(?P<varname>[^|]+)\|(?P<context>html|attr|js|css|url)$/', $data, $matches)) {
            return $tokenStruct;
        }

        return [
            $tokenStruct[0],
            $matches['varname'],
            $matches['context'],
        ];
    }
public function parse(array $tokenStruct)
    {
        if (! $tokenStruct[0] === Lexer::TOKEN_VARIABLE) {
            return $tokenStruct;
        }

        $data = $tokenStruct[1];
        if (! preg_match('/^(?P<varname>[^|]+)\|(?P<context>html|attr|js|css|url)$/', $data, $matches)) {
            return $tokenStruct;
        }

        return [
            $tokenStruct[0],
            $matches['varname'],
            $matches['context'],
        ];
    }
public function parse ( array $ tokenStruct ) { if ( ! $ tokenStruct [ 0 ] === Lexer :: TOKEN_VARIABLE ) { return $ tokenStruct ; } $ data = $ tokenStruct [ 1 ] ; if ( ! preg_match ( '/^(?P<varname>[^|]+)\|(?P<context>html|attr|js|css|url)$/' , $ data , $ matches ) ) { return $ tokenStruct ; } return [ $ tokenStruct [ 0 ] , $ matches [ 'varname' ] , $ matches [ 'context' ] , ] ; }
Escape a variable.

If the variable does not contain piping, or the context specified is not
understood, returns the struct without changes.

Otherwise, changes the data to be the value prior to the pipe, and puts
the context into the third element of the struct before returning it.

@param array $tokenStruct
@return array
Escape a variable .