public function parse() { static $i = 0; if ($i++) { throw new OnlyOnceException("I: Works only once", 1); } parent::parse(); }
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)); }
/** * @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)); }
/** * 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; }
/** * @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)); }