Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 public function parse()
 {
     static $i = 0;
     if ($i++) {
         throw new OnlyOnceException("I: Works only once", 1);
     }
     parent::parse();
 }
Exemplo n.º 3
0
 /**
  * @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));
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 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));
 }
Exemplo n.º 6
0
 public function __construct($input, $filename = null, array $options = array())
 {
     parent::__construct($input, $filename, $options);
     $this->lexer = new Lexer($this->input, $this->options);
 }