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


PHP Twig_Node::removeNode方法代碼示例

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


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

示例1: filterBodyNodes

 private function filterBodyNodes(Twig_Node $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->getLine(), $this->getFilename());
         }
         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->getLine(), $this->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 === $this->filterBodyNodes($n)) {
             $node->removeNode($k);
         }
     }
     return $node;
 }
開發者ID:vgrish,項目名稱:twiggy,代碼行數:23,代碼來源:Parser.php


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