示例#1
0
文件: Jade.php 项目: XaBerr/JUICE
 /**
  * Compile PHP code from a Pug input or a Pug file.
  *
  * @param string input
  *
  * @throws \Exception
  *
  * @return string
  */
 public function compile($input)
 {
     $parser = new Parser($input, null, $this->options);
     $compiler = new Compiler($this->options, $this->filters, $parser->getFilename());
     $php = $compiler->compile($parser->parse());
     if (version_compare(PHP_VERSION, '7.0.0') < 0) {
         $php = preg_replace_callback('/(' . preg_quote('\\Jade\\Compiler::getPropertyFromAnything', '/') . '\\(((?>[^()]+)|(?-2))*\\))[ \\t]*(\\(((?>[^()]+)|(?-2))*\\))/', function ($match) {
             return 'call_user_func(' . $match[1] . ', ' . $match[4] . ')';
         }, $php);
     }
     $postRender = $this->getOption('postRender');
     if (is_callable($postRender)) {
         $php = call_user_func($postRender, $php);
     }
     return $php;
 }