當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。