You are here

protected function Twig_NodeVisitor_Escaper::doEnterNode in Translation template extractor 7.3

Called before child nodes are visited.

Parameters

Twig_Node $node The node to visit:

Twig_Environment $env The Twig environment instance:

Return value

Twig_Node The modified node

Overrides Twig_BaseNodeVisitor::doEnterNode

File

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

Class

Twig_NodeVisitor_Escaper
Twig_NodeVisitor_Escaper implements output escaping.

Code

protected function doEnterNode(Twig_Node $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;
}