Example #1
0
 /**
  * parse currently set template
  * @return string (compiled PHP code)
  */
 protected function parse()
 {
     self::setIncludePath();
     require_once 'PHPTAL/Dom/DocumentBuilder.php';
     require_once 'PHPTAL/Php/CodeGenerator.php';
     self::restoreIncludePath();
     // instantiate the PHPTAL source parser
     $parser = new PHPTAL_Dom_SaxXmlParser($this->_encoding);
     $builder = new PHPTAL_Dom_DocumentBuilder();
     $builder->stripComments($this->_stripComments);
     $data = $this->_source->getData();
     $realpath = $this->_source->getRealPath();
     if ($this->_prefilter) {
         $data = $this->_prefilter->filter($data);
     }
     $tree = $parser->parseString($builder, $data, $realpath)->getResult();
     $generator = new PHPTAL_Php_CodeGenerator($this->getFunctionName(), $this->_source->getRealPath(), $this->_encoding, $this->_outputMode, $this->getCodePath());
     $result = $generator->generateCode($tree);
     return $result;
 }