Exemplo n.º 1
0
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     // 'svg'
     $name = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
     // %} (from {% stamp %})
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $aboveDumps = [];
     while (true) {
         // everything above {% stamp_dump %}
         $aboveDumps[] = $this->parser->subparse(function (\Twig_Token $token) {
             return $token->test('stamp_dump');
         });
         // allow nested {% stamp %} usage using distinct names
         $dumpName = $stream->next() && $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         if ($dumpName == $name) {
             break;
         }
     }
     // %} (from {% stamp_dump %})
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     // everything below {% stamp_dump %}
     $belowDump = $this->parser->subparse(function (\Twig_Token $token) {
         return $token->test('endstamp');
     });
     // %} (from {% endstamp %})
     $stream->next() && $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new StampNode($name, $aboveDumps, $belowDump, $lineno, $this->getTag());
 }
 /**
  * {@inheritdoc}
  */
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $name = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
     $options = [];
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if (!$stream->test(\Twig_Token::NAME_TYPE)) {
             $this->throwSyntaxError($stream);
         }
         $key = $stream->getCurrent()->getValue();
         $stream->next();
         if (!$stream->test(\Twig_Token::OPERATOR_TYPE, '=')) {
             $options[$key] = true;
             continue;
         }
         $stream->next();
         if (!$this->testOptionValue($stream)) {
             $this->throwSyntaxError($stream);
         }
         $options[$key] = $this->getOptionValue($stream);
         $stream->next();
     }
     $stream->next();
     $body = $this->parser->subparse(function (\Twig_Token $token) {
         return $token->test(['endcontenteditable']);
     }, true);
     if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
         throw new \Twig_Error_Syntax('A text inside a contenteditable tag must be a simple text.', $body->getLine(), $stream->getFilename());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new ContentEditableNode(['body' => $body], ['name' => $name, 'options' => $options], $lineno, $this->getTag());
 }
 /**
  * @see Twig_TokenParserInterface::parse()
  */
 public function parse(\Twig_Token $token)
 {
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(function (\Twig_Token $token) {
         return $token->test('endmarkdown');
     }, true);
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return new TwigMarkdownNode($body, $token->getLine(), $this->getTag());
 }
Exemplo n.º 4
0
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     // key, item in items
     $targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
     $stream->expect(\Twig_Token::OPERATOR_TYPE, 'in');
     $seq = $this->parser->getExpressionParser()->parseExpression();
     // as treeA
     $as = 'default';
     if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'as')) {
         $as = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     }
     // %}
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $data = array();
     while (true) {
         // backing up tag content
         $data[] = array('type' => 'body', 'node' => $this->parser->subparse(function (\Twig_Token $token) {
             return $token->test(array('subtree', 'endtree'));
         }));
         // {% subtree
         if ($stream->next()->getValue() == 'subtree') {
             // item
             $child = $this->parser->getExpressionParser()->parseExpression();
             // with treeA
             $with = $as;
             if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'with')) {
                 $with = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
             }
             // %}
             $stream->expect(\Twig_Token::BLOCK_END_TYPE);
             // backing up subtree details
             $data[] = array('type' => 'subtree', 'with' => $with, 'child' => $child);
             // {% endtree
         } else {
             // %}
             $stream->expect(\Twig_Token::BLOCK_END_TYPE);
             break;
         }
     }
     // key, item
     if (count($targets) > 1) {
         $keyTarget = $targets->getNode(0);
         $keyTarget = new \Twig_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getLine());
         $valueTarget = $targets->getNode(1);
         $valueTarget = new \Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine());
         // (implicit _key,) item
     } else {
         $keyTarget = new \Twig_Node_Expression_AssignName('_key', $lineno);
         $valueTarget = $targets->getNode(0);
         $valueTarget = new \Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine());
     }
     return new TreeNode($keyTarget, $valueTarget, $seq, $as, $data, $lineno, $this->getTag());
 }
Exemplo n.º 5
0
 /**
  * Разбирает выражение
  *
  * @param TwigToken $token Токен.
  *
  * @return WhileNode
  */
 public function parse(TwigToken $token)
 {
     $lineNumber = $token->getLine();
     $condition = $this->parser->getExpressionParser()->parseExpression();
     $stream = $this->parser->getStream();
     $stream->expect(TwigToken::BLOCK_END_TYPE);
     $callback = function (TwigToken $token) {
         return $token->test(['endwhile']);
     };
     $body = $this->parser->subparse($callback, true);
     $stream->expect(TwigToken::BLOCK_END_TYPE);
     return new WhileNode($condition, $body, $lineNumber, $this->getTag());
 }
Exemplo n.º 6
0
 public function decideBlockEnd(Twig_Token $token)
 {
     return $token->test('endfilter');
 }
 public function testEndTag(\Twig_Token $token)
 {
     return $token->test(array('end' . $this->getTag()));
 }
Exemplo n.º 8
0
Arquivo: For.php Projeto: Jimm31/Kassa
 public function decideForEnd(Twig_Token $token)
 {
     return $token->test('endfor');
 }
Exemplo n.º 9
0
 public function decideBlockEnd(Twig_Token $token)
 {
     return $token->test('endautoescape');
 }
Exemplo n.º 10
0
 /**
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function decideCacheEnd(\Twig_Token $token)
 {
     return $token->test('endcache');
 }
Exemplo n.º 11
0
 /**
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function decideNavEnd(\Twig_Token $token)
 {
     return $token->test('endnav');
 }
Exemplo n.º 12
0
 public function decideMarkdownEnd(Twig_Token $token)
 {
     return $token->test('endmarkdown');
 }
 /**
  * @param Twig_Token $token
  * @return bool
  */
 public function decideHmacEnd(\Twig_Token $token)
 {
     return $token->test('endhmac');
 }
Exemplo n.º 14
0
 public function decideWithEnd(Twig_Token $token)
 {
     return $token->test('endwith');
 }
 public function decideStopwatchEnd(\Twig_Token $token)
 {
     return $token->test('endstopwatch');
 }
Exemplo n.º 16
0
 public function decideIfEnd(Twig_Token $token)
 {
     return $token->test(array('endif'));
 }
 /**
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function decideEnd(\Twig_Token $token)
 {
     return $token->test('endcontainer');
 }
 /**
  * Test for end tag
  *
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function testEndTag(\Twig_Token $token)
 {
     return $token->test(['end' . $this->tag]);
 }
 public function decideGimmeListFork(\Twig_Token $token)
 {
     return $token->test(['else', 'endgimmelist']);
 }
Exemplo n.º 20
0
 public function decideBlockEnd(\Twig_Token $token)
 {
     return $token->test('endassets');
 }
Exemplo n.º 21
0
 /**
  * Define how a page tag ends. Returns `endpage`.
  *
  *
  * @param \Twig_Token $token An instance of a \Twig_Token.
  *
  * @return string
  */
 public function endOfTag(\Twig_Token $token)
 {
     return $token->test('endpage');
 }
Exemplo n.º 22
0
 public function decideEnd(\Twig_Token $token)
 {
     return $token->test(array('endtry'));
 }
Exemplo n.º 23
0
 public function decideSpacelessEnd(Twig_Token $token)
 {
     return $token->test('endspaceless');
 }
 public function decideBlockEnd(\Twig_Token $token)
 {
     return $token->test('end_ui_sections');
 }
Exemplo n.º 25
0
 /**
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function decideRoleEnd(\Twig_Token $token)
 {
     return $token->test('endrole');
 }
 public function decideCSPScriptEnd(\Twig_Token $token)
 {
     return $token->test('end' . $this->tag);
 }
Exemplo n.º 27
0
 public function decideBlockEnd(Twig_Token $token)
 {
     return $token->test('endsandbox');
 }
Exemplo n.º 28
0
 public function decideBlockEnd(\Twig_Token $token)
 {
     return $token->test('ENDDEFINE');
 }
Exemplo n.º 29
0
 protected function isBinary(Twig_Token $token)
 {
     return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
 }
Exemplo n.º 30
0
 public function decideIfVariant(\Twig_Token $token)
 {
     return $token->test(array('variant', 'endab'));
 }