You are here

public function Twig_NodeVisitor_Escaper::enterNode in Translation template extractor 6.3

Called before child nodes are visited.

Parameters

Twig_NodeInterface $node The node to visit:

Twig_Environment $env The Twig environment instance:

Return value

Twig_NodeInterface The modified node

Overrides Twig_NodeVisitorInterface::enterNode

File

vendor/Twig/NodeVisitor/Escaper.php, line 39

Class

Twig_NodeVisitor_Escaper
Twig_NodeVisitor_Escaper implements output escaping.

Code

public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) {
  if ($node instanceof Twig_Node_Module) {
    if ($env
      ->hasExtension('escaper') && ($defaultStrategy = $env
      ->getExtension('escaper')
      ->getDefaultStrategy($node
      ->getAttribute('filename')))) {
      $this->defaultStrategy = $defaultStrategy;
    }
    $this->safeVars = array();
  }
  elseif ($node instanceof Twig_Node_AutoEscape) {
    $this->statusStack[] = $node
      ->getAttribute('value');
  }
  elseif ($node instanceof Twig_Node_Block) {
    $this->statusStack[] = isset($this->blocks[$node
      ->getAttribute('name')]) ? $this->blocks[$node
      ->getAttribute('name')] : $this
      ->needEscaping($env);
  }
  elseif ($node instanceof Twig_Node_Import) {
    $this->safeVars[] = $node
      ->getNode('var')
      ->getAttribute('name');
  }
  return $node;
}