1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-21 11:56:04 +01:00
vichan/inc/lib/Twig/Node/Import.php

52 lines
1.4 KiB
PHP
Raw Normal View History

2011-10-05 06:22:53 +02:00
<?php
/*
* This file is part of Twig.
*
2018-05-10 12:24:53 +02:00
* (c) Fabien Potencier
2011-10-05 06:22:53 +02:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Represents an import node.
*
2013-08-01 21:20:12 +02:00
* @author Fabien Potencier <fabien@symfony.com>
2011-10-05 06:22:53 +02:00
*/
class Twig_Node_Import extends Twig_Node
{
public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null)
{
parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
}
public function compile(Twig_Compiler $compiler)
{
$compiler
->addDebugInfo($this)
->write('')
->subcompile($this->getNode('var'))
->raw(' = ')
;
if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
2018-05-10 12:24:53 +02:00
$compiler->raw('$this');
2011-10-05 06:22:53 +02:00
} else {
$compiler
2018-05-10 12:24:53 +02:00
->raw('$this->loadTemplate(')
2011-10-05 06:22:53 +02:00
->subcompile($this->getNode('expr'))
2018-05-10 12:24:53 +02:00
->raw(', ')
->repr($this->getTemplateName())
->raw(', ')
->repr($this->getTemplateLine())
->raw(')')
2011-10-05 06:22:53 +02:00
;
}
$compiler->raw(";\n");
}
}
2018-05-10 12:24:53 +02:00
class_alias('Twig_Node_Import', 'Twig\Node\ImportNode', false);