public function testTokenizeBlocks() { $this->assertEquals(array('{%comment%}'), Template::tokenize('{%comment%}')); $this->assertEquals(array(' ', '{%comment%}', ' '), Template::tokenize(' {%comment%} ')); $this->assertEquals(array(' ', '{%comment%}', ' ', '{%endcomment%}', ' '), Template::tokenize(' {%comment%} {%endcomment%} ')); $this->assertEquals(array(' ', '{% comment %}', ' ', '{% endcomment %}', ' '), Template::tokenize(" {% comment %} {% endcomment %} ")); }
public function __invoke(array $args = null, $str = null) { $str = isset($str) ? $str : $this->string; // Apply passed arguments as priority. if (isset($args)) { list($find, $replace) = $this->prepare($args, false); } elseif ($this->substitutions) { list($find, $replace) = $this->substitutions; } // Apply substitutions. $str = isset($find) ? str_replace($find, $replace, $str) : $str; return Template::tokenize($str); }
/** * Parses the given source string * * @param string $source * * @return Template */ public function parse($source) { if (self::$cache !== null) { if (($this->root = self::$cache->read(md5($source))) != false && $this->root->checkIncludes() != true) { } else { $tokens = Template::tokenize($source); $this->root = new Document($tokens, $this->fileSystem); self::$cache->write(md5($source), $this->root); } } else { $tokens = Template::tokenize($source); $this->root = new Document($tokens, $this->fileSystem); } return $this; }
function loop($process) { $process->string->pregReplaceCallback(LOOP_PATT, function ($m) { return Template::tokenize(loop_unroll(Template::unTokenize($m[0]))); }); }