public function tokenize($template, $cacheTokens = true)
    {
        $lexer = $this->getLexer();
        if (false !== strstr($template, '{{')) {
            return $lexer->compile($this, $template);
        }

        if ($cacheTokens
            && array_key_exists($template, $this->cachedTemplates)
            && is_array($this->cachedTemplates[$template])
        ) {
            return $this->cachedTemplates[$template];
        }

        $templateOrTokens = $this->fetchTemplate($template);

        if (is_string($templateOrTokens)) {
            $templateOrTokens = $lexer->compile($this, $templateOrTokens, $template);
        }

        if ($templateOrTokens instanceof Traversable) {
            $templateOrTokens = iterator_to_array($templateOrTokens);
        }

        if (! is_array($templateOrTokens)) {
            throw new Exception\InvalidTokensException(sprintf(
                '%s was unable to either retrieve or compile tokens',
                __METHOD__
            ));
        }

        if ($cacheTokens) {
            $this->cachedTemplates[$template] = $templateOrTokens;
        }

        return $templateOrTokens;
    }
public function tokenize($template, $cacheTokens = true)
    {
        $lexer = $this->getLexer();
        if (false !== strstr($template, '{{')) {
            return $lexer->compile($this, $template);
        }

        if ($cacheTokens
            && array_key_exists($template, $this->cachedTemplates)
            && is_array($this->cachedTemplates[$template])
        ) {
            return $this->cachedTemplates[$template];
        }

        $templateOrTokens = $this->fetchTemplate($template);

        if (is_string($templateOrTokens)) {
            $templateOrTokens = $lexer->compile($this, $templateOrTokens, $template);
        }

        if ($templateOrTokens instanceof Traversable) {
            $templateOrTokens = iterator_to_array($templateOrTokens);
        }

        if (! is_array($templateOrTokens)) {
            throw new Exception\InvalidTokensException(sprintf(
                '%s was unable to either retrieve or compile tokens',
                __METHOD__
            ));
        }

        if ($cacheTokens) {
            $this->cachedTemplates[$template] = $templateOrTokens;
        }

        return $templateOrTokens;
    }
public function tokenize ( $ template , $ cacheTokens = true ) { $ lexer = $ this -> getLexer ( ) ; if ( false !== strstr ( $ template , '{{' ) ) { return $ lexer -> compile ( $ this , $ template ) ; } if ( $ cacheTokens && array_key_exists ( $ template , $ this -> cachedTemplates ) && is_array ( $ this -> cachedTemplates [ $ template ] ) ) { return $ this -> cachedTemplates [ $ template ] ; } $ templateOrTokens = $ this -> fetchTemplate ( $ template ) ; if ( is_string ( $ templateOrTokens ) ) { $ templateOrTokens = $ lexer -> compile ( $ this , $ templateOrTokens , $ template ) ; } if ( $ templateOrTokens instanceof Traversable ) { $ templateOrTokens = iterator_to_array ( $ templateOrTokens ) ; } if ( ! is_array ( $ templateOrTokens ) ) { throw new Exception \ InvalidTokensException ( sprintf ( '%s was unable to either retrieve or compile tokens' , __METHOD__ ) ) ; } if ( $ cacheTokens ) { $ this -> cachedTemplates [ $ template ] = $ templateOrTokens ; } return $ templateOrTokens ; }
Tokenize a template

@param  string $template Either a template string or a reference to a template
@param  boolean $cacheTokens Whether or not to cache tokens for the given template
@return array Array of tokens
Tokenize a template