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

55 lines
1.4 KiB
PHP
Raw Normal View History

2011-10-05 06:22:53 +02:00
<?php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* 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);
}
/**
* Compiles the node to PHP.
*
2015-03-11 00:16:45 +01:00
* @param Twig_Compiler $compiler A Twig_Compiler instance
2011-10-05 06:22:53 +02:00
*/
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')) {
$compiler->raw("\$this");
} else {
$compiler
2015-03-11 00:16:45 +01:00
->raw('$this->loadTemplate(')
2011-10-05 06:22:53 +02:00
->subcompile($this->getNode('expr'))
2015-03-11 00:16:45 +01:00
->raw(', ')
->repr($compiler->getFilename())
->raw(', ')
->repr($this->getLine())
2011-10-05 06:22:53 +02:00
->raw(")")
;
}
$compiler->raw(";\n");
}
}