示例#1
0
 public function parse()
 {
     static $i = 0;
     if ($i++) {
         throw new OnlyOnceException("I: Works only once", 1);
     }
     parent::parse();
 }
示例#2
0
文件: Jade.php 项目: SC7639/jade.php
 public function render($input, $scope = null, $includes = array())
 {
     if ($scope !== null && is_array($scope)) {
         extract($scope);
     }
     $parser = new Parser($input, array('includes' => $includes));
     $compiler = new Compiler($this->prettyprint);
     return $compiler->compile($parser->parse($input));
 }
示例#3
0
文件: Jade.php 项目: volter9/jade-php
 /**
  * @param $input
  * @return string
  */
 public function compile($input)
 {
     $parser = new Parser($input, null, $this->options['extension']);
     $compiler = new Compiler($this->options['prettyprint'], $this->options['phpSingleLine'], $this->options['allowMixinOverride'], $this->filters);
     return $compiler->compile($parser->parse($input));
 }
示例#4
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;
 }
示例#5
0
 /**
  * @param $input
  * @return string
  */
 public function compile($input)
 {
     $parser = new Parser($input, null, $this->options['extension']);
     $compiler = new Compiler($this->options['prettyprint'], $this->filters);
     return $compiler->compile($parser->parse($input));
 }