source: pro-violet-viettel/sourcecode/application/third_party/Twig/Node/Expression/Name.php @ 345

Last change on this file since 345 was 345, checked in by quyenla, 11 years ago

collaborator page

File size: 1.1 KB
Line 
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) 2009 Fabien Potencier
7 * (c) 2009 Armin Ronacher
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12class Twig_Node_Expression_Name extends Twig_Node_Expression
13{
14    public function __construct($name, $lineno)
15    {
16        parent::__construct(array(), array('name' => $name), $lineno);
17    }
18
19    public function compile(Twig_Compiler $compiler)
20    {
21        if ('_self' === $this->getAttribute('name')) {
22            $compiler->raw('$this');
23        } elseif ('_context' === $this->getAttribute('name')) {
24            $compiler->raw('$context');
25        } elseif ('_charset' === $this->getAttribute('name')) {
26            $compiler->raw('$this->env->getCharset()');
27        } elseif ($compiler->getEnvironment()->isStrictVariables()) {
28            $compiler->raw(sprintf('$this->getContext($context, \'%s\')', $this->getAttribute('name')));
29        } else {
30            $compiler->raw(sprintf('(isset($context[\'%s\']) ? $context[\'%s\'] : null)', $this->getAttribute('name'), $this->getAttribute('name')));
31        }
32    }
33}
Note: See TracBrowser for help on using the repository browser.