public function visit(Twig_Node $node) { // filter? if ($node instanceof Twig_Node_Filter) { $this->statusStack[] = $node->getFilters(); $node = $this->visitDeep($node); array_pop($this->statusStack); return $node; } if (!$node instanceof Twig_Node_Print && !$node instanceof Twig_Node_Text) { return $this->visitDeep($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()); } }
public function enterNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Filter) { $this->statusStack[] = $node->getFilters(); } elseif ($node instanceof Twig_Node_Print || $node instanceof Twig_Node_Text) { return $this->applyFilters($node); } return $node; }
public function enterNode(Twig_Node $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->getTag()) { $this->tags[$node->getTag()] = true; } // look for filters if ($node instanceof Twig_Node_Expression_Filter) { foreach ($node->getFilters() as $filter) { $this->filters[$filter[0]] = true; } } } return $node; }