/** * @param string $file * @return array * @todo Implements .proto file parsing into PHP array */ public function parse($file) { $filename = $this->rootPath . $file; // $cacheFile = $this->cachePath . $file . '.php'; // if (is_readable($cacheFile)) { // $data = include $cacheFile; // return $data; // } $source = file_get_contents($filename); $tokens = Tokenizer::parse($source); $data = $tokens; return $tokens; }
/** * Render the Mustache template * @param array $scope (optional) The scope to start working from on the parameters. * @return string Returns the parsed template * @since 1.0-sofia */ public function render($scope = array()) { $this->loadParameters(); $tokenizer = new Tokenizer(); $tokenizer->changeDelimiters($this->openDelimiter, $this->closeDelimiter); $tokens = $tokenizer->parse($this->template); $this->line = 1; $buffer = $this->parse($scope, $tokens); return $buffer; }
/** * Parses a full HTML document. * @param $text HTML text to parse * @param $builder Custom builder implementation * @return Parsed HTML as DOMDocument */ public static function parse($text, $builder = null) { $tokenizer = new Tokenizer($text, $builder); $tokenizer->parse(); return $tokenizer->save(); }