当前位置: 首页>>代码示例>>PHP>>正文


PHP Twig_Token::test方法代码示例

本文整理汇总了PHP中Twig_Token::test方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Token::test方法的具体用法?PHP Twig_Token::test怎么用?PHP Twig_Token::test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twig_Token的用法示例。


在下文中一共展示了Twig_Token::test方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 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());
 }
开发者ID:blablacar,项目名称:twig-stamp,代码行数:30,代码来源:StampTokenParser.php

示例2: parse

 /**
  * {@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());
 }
开发者ID:ivoaz,项目名称:content-editable-bundle,代码行数:36,代码来源:ContentEditableTokenParser.php

示例3: parse

 /**
  * @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());
 }
开发者ID:allmarkedup,项目名称:twig-extensions,代码行数:12,代码来源:TwigMarkdownTokenParser.php

示例4: parse

 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());
 }
开发者ID:ninsuo,项目名称:jordan-tree,代码行数:55,代码来源:TreeTokenParser.php

示例5: parse

 /**
  * Разбирает выражение
  *
  * @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());
 }
开发者ID:free2er,项目名称:twig-extensions,代码行数:20,代码来源:WhileTokenParser.php

示例6: testEndTag

 public function testEndTag(\Twig_Token $token)
 {
     return $token->test(array('end' . $this->getTag()));
 }
开发者ID:electrotiti,项目名称:tlassets-bundle,代码行数:4,代码来源:TlAssetsTokenParser.php

示例7: decideForEnd

 public function decideForEnd(Twig_Token $token)
 {
     return $token->test('endfor');
 }
开发者ID:Jimm31,项目名称:Kassa,代码行数:4,代码来源:For.php

示例8: decideBlockEnd

 public function decideBlockEnd(Twig_Token $token)
 {
     return $token->test('endautoescape');
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:4,代码来源:AutoEscape.php

示例9: decideCacheEnd

 /**
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function decideCacheEnd(\Twig_Token $token)
 {
     return $token->test('endcache');
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:9,代码来源:Cache_TokenParser.php

示例10: decideNavEnd

 /**
  * @param \Twig_Token $token
  *
  * @return bool
  */
 public function decideNavEnd(\Twig_Token $token)
 {
     return $token->test('endnav');
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:9,代码来源:Nav_TokenParser.php

示例11: decideMarkdownEnd

 public function decideMarkdownEnd(Twig_Token $token)
 {
     return $token->test('endmarkdown');
 }
开发者ID:natxet,项目名称:Twig-extensions,代码行数:4,代码来源:Markdown.php

示例12: decideHmacEnd

 /**
  * @param Twig_Token $token
  * @return bool
  */
 public function decideHmacEnd(\Twig_Token $token)
 {
     return $token->test('endhmac');
 }
开发者ID:digitaldevelopers,项目名称:foxycart-craft,代码行数:8,代码来源:Hmac_TokenParser.php

示例13: decideWithEnd

 public function decideWithEnd(Twig_Token $token)
 {
     return $token->test('endwith');
 }
开发者ID:naldz,项目名称:cyberden,代码行数:4,代码来源:With.php

示例14: decideStopwatchEnd

 public function decideStopwatchEnd(\Twig_Token $token)
 {
     return $token->test('endstopwatch');
 }
开发者ID:barryvdh,项目名称:laravel-debugbar,代码行数:4,代码来源:StopwatchTokenParser.php

示例15: decideIfEnd

 public function decideIfEnd(Twig_Token $token)
 {
     return $token->test(array('endif'));
 }
开发者ID:hoque92,项目名称:hoquezilla,代码行数:4,代码来源:If.php


注:本文中的Twig_Token::test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。