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


PHP Twig_NodeInterface::getExpression方法代碼示例

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


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

示例1: enterNode

 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Module) {
         $this->inAModule = true;
         $this->tags = array();
         $this->filters = array();
         return $node;
     } elseif ($this->inAModule) {
         // look for tags
         if ($node->getNodeTag()) {
             $this->tags[$node->getNodeTag()] = true;
         }
         // look for filters
         if ($node instanceof Twig_Node_Expression_Filter) {
             foreach ($node->getFilters() as $filter) {
                 $this->filters[$filter[0]] = true;
             }
         }
         // look for simple print statement ({{ article }})
         if ($node instanceof Twig_Node_Print && $node->getExpression() instanceof Twig_Node_Expression_Name) {
             return new Twig_Node_SandboxPrint($node->getExpression(), $node->getLine(), $node->getNodeTag());
         }
     }
     return $node;
 }
開發者ID:nmcteam,項目名稱:Twig,代碼行數:25,代碼來源:Sandbox.php

示例2: applyFilters

 protected function applyFilters(Twig_NodeInterface $node)
 {
     if (false === ($filters = $this->getCurrentFilters())) {
         return $node;
     }
     if ($node instanceof Twig_Node_Text) {
         $expression = new Twig_Node_Expression_Constant($node->getData(), $node->getLine());
     } else {
         $expression = $node->getExpression();
     }
     // filters
     if ($expression instanceof Twig_Node_Expression_Filter) {
         $expression->appendFilters($filters);
         return $node;
     } else {
         return new Twig_Node_Print(new Twig_Node_Expression_Filter($expression, $filters, $node->getLine()), $node->getLine());
     }
 }
開發者ID:nmcteam,項目名稱:Twig,代碼行數:18,代碼來源:Filter.php

示例3: escapeNode

 protected function escapeNode(Twig_NodeInterface $node, Twig_Environment $env, $type)
 {
     if (false === $type) {
         return $node;
     }
     $expression = $node instanceof Twig_Node_Print ? $node->getExpression() : $node;
     if ($expression instanceof Twig_Node_Expression_Filter) {
         // don't escape if the primary node of the filter is not a variable
         $nodes = $expression->getNodes();
         if (!$nodes[0] instanceof Twig_Node_Expression_Name) {
             return $node;
         }
         // don't escape if there is already an "escaper" in the filter chain
         $filterMap = $env->getFilters();
         foreach ($expression->getFilters() as $filter) {
             if (isset($filterMap[$filter[0]]) && $filterMap[$filter[0]]->isEscaper()) {
                 return $node;
             }
         }
     } elseif (!$expression instanceof Twig_Node_Expression_GetAttr && !$expression instanceof Twig_Node_Expression_Name) {
         // don't escape if the node is not a variable
         return $node;
     }
     // escape
     if ($expression instanceof Twig_Node_Expression_Filter) {
         // escape all variables in filters arguments
         $filters = $expression->getFilters();
         foreach ($filters as $i => $filter) {
             foreach ($filter[1] as $j => $argument) {
                 $filters[$i][1][$j] = $this->escapeNode($argument, $env, $type);
             }
         }
         $expression->setFilters($filters);
         $expression->prependFilter($this->getEscaperFilter($type));
         return $node;
     } elseif ($node instanceof Twig_Node_Print) {
         return new Twig_Node_Print(new Twig_Node_Expression_Filter($expression, array($this->getEscaperFilter($type)), $node->getLine()), $node->getLine());
     } else {
         return new Twig_Node_Expression_Filter($node, array($this->getEscaperFilter($type)), $node->getLine());
     }
 }
開發者ID:nmcteam,項目名稱:Twig,代碼行數:41,代碼來源:Escaper.php


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