/**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf('block') && $stream->expect('(')) {
         return sprintf("\$this->getExtension('core')->startBlock%s", $this->parser->parseExpression());
     }
     if ($stream->nextIf('endblock')) {
         return "echo(\$this->getExtension('core')->endBlock())";
     }
 }
Example #2
0
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf($this->name) && $stream->expect('(')) {
         $out = sprintf("\$this->getDirective('%s')->call(%s)", $this->name, $stream->test('(') ? 'array' . $this->parser->parseExpression() : '');
         if ($this->escape) {
             $out = sprintf("\$this->escape(%s)", $out);
         }
         return sprintf("echo(%s)", $out);
     }
 }
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf('raw') && $stream->expect('(')) {
         $out = 'echo';
         while (!$stream->test(T_CLOSE_TAG)) {
             $out .= $this->parser->parseExpression();
         }
         return $out;
     }
 }
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf(['trans', 'transchoice']) && $stream->expect('(')) {
         $out = 'echo ' . ($token->test('trans') ? '__' : '_c');
         while (!$stream->test(T_CLOSE_TAG)) {
             $out .= $this->parser->parseExpression();
         }
         return $out;
     }
 }
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     $control = in_array($token->getType(), $this->control);
     if ($control || in_array($token->getType(), $this->controlEnd)) {
         $out = '';
         while (!$stream->test(T_CLOSE_TAG)) {
             $out .= $this->parser->parseExpression();
         }
         if ($control) {
             $out .= ':';
         }
         return $out;
     }
 }
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf('section') && $stream->expect('(')) {
         $stack = [true];
         while (!empty($stack) && ($token = $stream->peekUntil(T_COMMENT, '/* DIRECTIVE */'))) {
             if ($token = $stream->peek()) {
                 if ($token->test('section')) {
                     $stack[] = true;
                 }
                 if ($token->test('endsection')) {
                     array_pop($stack);
                 }
             }
         }
         $stream->resetPeek();
         return sprintf("\$app['view.sections']->%s%s", empty($stack) ? 'start' : 'output', $this->parser->parseExpression());
     }
     if ($stream->nextIf('endsection')) {
         return "echo(\$app['view.sections']->end())";
     }
 }
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf('extend') && $stream->expect('(')) {
         return sprintf("\$this->extend%s", $this->parser->parseExpression());
     }
 }
 /**
  * @{inheritdoc}
  */
 public function parse(TokenStream $stream, Token $token)
 {
     if ($stream->nextIf('include') && $stream->expect('(')) {
         return sprintf("\$_defined = array%s; echo(\$this->render(\$_defined[0], array_merge(get_defined_vars(), isset(\$_defined[1]) ? \$_defined[1] : [])))", $this->parser->parseExpression());
     }
 }