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


PHP Twig_NodeInterface::getTemplateLine方法代码示例

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


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

示例1: __construct

 public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
 {
     $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getTemplateLine()), $arguments, $node->getTemplateLine());
     if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) {
         $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getTemplateLine());
         $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getTemplateLine());
         $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getTemplateLine());
     } else {
         $node = $default;
     }
     parent::__construct($node, $filterName, $arguments, $lineno, $tag);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:12,代码来源:Default.php

示例2: __construct

 public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
 {
     $test = new Twig_Node_Expression_Binary_And(new Twig_Node_Expression_Test_Defined(clone $left, 'defined', new Twig_Node(), $left->getTemplateLine()), new Twig_Node_Expression_Unary_Not(new Twig_Node_Expression_Test_Null($left, 'null', new Twig_Node(), $left->getTemplateLine()), $left->getTemplateLine()), $left->getTemplateLine());
     parent::__construct($test, $left, $right, $lineno);
 }
开发者ID:bigbitecreative,项目名称:wordpress-git-content,代码行数:5,代码来源:NullCoalesce.php

示例3: checkLoopUsageBody

 protected function checkLoopUsageBody(Twig_TokenStream $stream, Twig_NodeInterface $node)
 {
     if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
         $attribute = $node->getNode('attribute');
         if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
             throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getTemplateLine(), $stream->getSourceContext()->getName());
         }
     }
     // should check for parent.loop.XXX usage
     if ($node instanceof Twig_Node_For) {
         return;
     }
     foreach ($node as $n) {
         if (!$n) {
             continue;
         }
         $this->checkLoopUsageBody($stream, $n);
     }
 }
开发者ID:naldz,项目名称:cyberden,代码行数:19,代码来源:For.php

示例4: getEscaperFilter

 protected function getEscaperFilter($type, Twig_NodeInterface $node)
 {
     $line = $node->getTemplateLine();
     $name = new Twig_Node_Expression_Constant('escape', $line);
     $args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)));
     return new Twig_Node_Expression_Filter($node, $name, $args, $line);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:7,代码来源:Escaper.php

示例5: parseTestExpression

 private function parseTestExpression(Twig_NodeInterface $node)
 {
     $stream = $this->parser->getStream();
     list($name, $test) = $this->getTest($node->getTemplateLine());
     $class = $this->getTestNodeClass($test);
     $arguments = null;
     if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
         $arguments = $this->parser->getExpressionParser()->parseArguments(true);
     }
     return new $class($node, $name, $arguments, $this->parser->getCurrentToken()->getLine());
 }
开发者ID:bigbitecreative,项目名称:wordpress-git-content,代码行数:11,代码来源:ExpressionParser.php

示例6: addDebugInfo

 /**
  * Adds debugging information.
  *
  * @return $this
  */
 public function addDebugInfo(Twig_NodeInterface $node)
 {
     if ($node->getTemplateLine() != $this->lastLine) {
         $this->write(sprintf("// line %d\n", $node->getTemplateLine()));
         // when mbstring.func_overload is set to 2
         // mb_substr_count() replaces substr_count()
         // but they have different signatures!
         if ((int) ini_get('mbstring.func_overload') & 2) {
             // this is much slower than the "right" version
             $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
         } else {
             $this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
         }
         $this->sourceOffset = strlen($this->source);
         $this->debugInfo[$this->sourceLine] = $node->getTemplateLine();
         $this->lastLine = $node->getTemplateLine();
     }
     return $this;
 }
开发者ID:naldz,项目名称:cyberden,代码行数:24,代码来源:Compiler.php

示例7: filterBodyNodes

 protected function filterBodyNodes(Twig_NodeInterface $node)
 {
     // check that the body does not contain non-empty output nodes
     if ($node instanceof Twig_Node_Text && !ctype_space($node->getAttribute('data')) || !$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface) {
         if (false !== strpos((string) $node, chr(0xef) . chr(0xbb) . chr(0xbf))) {
             throw new Twig_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext()->getName());
         }
         throw new Twig_Error_Syntax('A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext()->getName());
     }
     // bypass "set" nodes as they "capture" the output
     if ($node instanceof Twig_Node_Set) {
         return $node;
     }
     if ($node instanceof Twig_NodeOutputInterface) {
         return;
     }
     foreach ($node as $k => $n) {
         if (null !== $n && null === $this->filterBodyNodes($n)) {
             $node->removeNode($k);
         }
     }
     return $node;
 }
开发者ID:bigbitecreative,项目名称:wordpress-git-content,代码行数:23,代码来源:Parser.php


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