當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Twig_Parser::getStream方法代碼示例

本文整理匯總了PHP中Twig_Parser::getStream方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Parser::getStream方法的具體用法?PHP Twig_Parser::getStream怎麽用?PHP Twig_Parser::getStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Twig_Parser的用法示例。


在下文中一共展示了Twig_Parser::getStream方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse

 /** {@inheritDoc} */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $lineno = $stream->getCurrent()->getLine();
     // Export type: "js" or "css"
     $export_type = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     if (!in_array($export_type, ['js', 'css', 'inline'])) {
         // This exception will include the template filename by itself.
         throw new \Twig_Error_Syntax(sprintf('Expected export type "inline", "js" or "css", got "%s" at line %d.', $export_type, $lineno));
     }
     if ($export_type === "inline") {
         return $this->parseInline($stream, $lineno);
     }
     return $this->parseType($stream, $lineno, $export_type);
 }
開發者ID:emilnordh,項目名稱:webpack-bundle,代碼行數:16,代碼來源:WebpackTokenParser.php

示例2: parseTestExpression

 public function parseTestExpression(Twig_Parser $parser, $node)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE);
     $arguments = null;
     if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
         $arguments = $parser->getExpressionParser()->parseArguments();
     }
     return new Twig_Node_Expression_Test($node, $name->getValue(), $arguments, $parser->getCurrentToken()->getLine());
 }
開發者ID:kuslahne,項目名稱:rapid-slim-php-blog-application,代碼行數:10,代碼來源:Core.php

示例3: parseTestExpression

 public function parseTestExpression(Twig_Parser $parser, $node)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
     $arguments = null;
     if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
         $arguments = $parser->getExpressionParser()->parseArguments();
     }
     $class = $this->getTestNodeClass($parser->getEnvironment(), $name);
     return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
 }
開發者ID:carlesgutierrez,項目名稱:libreobjet.org,代碼行數:11,代碼來源:Core.php

示例4: getTestName

 protected function getTestName(Twig_Parser $parser, $line)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
     $env = $parser->getEnvironment();
     $testMap = $env->getTests();
     if (isset($testMap[$name])) {
         return $name;
     }
     if ($stream->test(Twig_Token::NAME_TYPE)) {
         // try 2-words tests
         $name = $name . ' ' . $parser->getCurrentToken()->getValue();
         if (isset($testMap[$name])) {
             $parser->getStream()->next();
             return $name;
         }
     }
     $message = sprintf('The test "%s" does not exist', $name);
     if ($alternatives = $env->computeAlternatives($name, array_keys($testMap))) {
         $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
     }
     throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
 }
開發者ID:stler,項目名稱:NMFrame,代碼行數:23,代碼來源:Core.php

示例5: getTestNodeClass

 protected function getTestNodeClass(Twig_Parser $parser, $name, $line)
 {
     $env = $parser->getEnvironment();
     $testMap = $env->getTests();
     $testName = null;
     if (isset($testMap[$name])) {
         $testName = $name;
     } elseif ($parser->getStream()->test(Twig_Token::NAME_TYPE)) {
         // try 2-words tests
         $name = $name . ' ' . $parser->getCurrentToken()->getValue();
         if (isset($testMap[$name])) {
             $parser->getStream()->next();
             $testName = $name;
         }
     }
     if (null === $testName) {
         $message = sprintf('The test "%s" does not exist', $name);
         if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
             $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
         }
         throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
     }
     if ($testMap[$name] instanceof Twig_SimpleTest) {
         return $testMap[$name]->getNodeClass();
     }
     return $testMap[$name] instanceof Twig_Test_Node ? $testMap[$name]->getClass() : 'Twig_Node_Expression_Test';
 }
開發者ID:TiGR,項目名稱:Twig,代碼行數:27,代碼來源:Core.php

示例6: getTest

 protected function getTest(Twig_Parser $parser, $line)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
     $env = $parser->getEnvironment();
     if ($test = $env->getTest($name)) {
         return array($name, $test);
     }
     if ($stream->test(Twig_Token::NAME_TYPE)) {
         // try 2-words tests
         $name = $name . ' ' . $parser->getCurrentToken()->getValue();
         if ($test = $env->getTest($name)) {
             $parser->getStream()->next();
             return array($name, $test);
         }
     }
     $e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $parser->getFilename());
     $e->addSuggestions($name, array_keys($env->getTests()));
     throw $e;
 }
開發者ID:hoque92,項目名稱:hoquezilla,代碼行數:20,代碼來源:Core.php

示例7: moveToNextNode

 public function moveToNextNode(\Twig_Parser $parser)
 {
     $parser->getStream()->next();
     $parser->getStream()->expect(\Twig_Token::BLOCK_START_TYPE);
 }
開發者ID:ner0tic,項目名稱:YepsuaSmarTwigBundle,代碼行數:5,代碼來源:CommonTokenParser.php


注:本文中的Twig_Parser::getStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。