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


PHP Twig_NodeInterface::removeNode方法代码示例

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


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

示例1: 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 have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->getLine(), $this->stream->getFilename());
         } else {
             throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->stream->getFilename());
         }
     }
     // 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 === ($n = $this->filterBodyNodes($n))) {
             $node->removeNode($k);
         }
     }
     return $node;
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:24,代码来源:Parser.php

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