You are here

protected function Twig_Node_Module::compileLoadTemplate in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Node/Module.php \Twig_Node_Module::compileLoadTemplate()
1 call to Twig_Node_Module::compileLoadTemplate()
Twig_Node_Module::compileConstructor in vendor/Twig/Node/Module.php

File

vendor/Twig/Node/Module.php, line 361

Class

Twig_Node_Module
Represents a module node.

Code

protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var) {
  if ($node instanceof Twig_Node_Expression_Constant) {
    $compiler
      ->write(sprintf("%s = \$this->env->loadTemplate(", $var))
      ->subcompile($node)
      ->raw(");\n");
  }
  else {
    $compiler
      ->write(sprintf("%s = ", $var))
      ->subcompile($node)
      ->raw(";\n")
      ->write(sprintf("if (!%s", $var))
      ->raw(" instanceof Twig_Template) {\n")
      ->indent()
      ->write(sprintf("%s = \$this->env->loadTemplate(%s);\n", $var, $var))
      ->outdent()
      ->write("}\n");
  }
}