From 874b8cbf002e9d8bf0ff39671e1501165016320a Mon Sep 17 00:00:00 2001 From: Michael Save Date: Mon, 9 Apr 2012 20:52:26 +1000 Subject: inc/contrib -> inc/lib --- inc/lib/Twig/Node/Expression/Name.php | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 inc/lib/Twig/Node/Expression/Name.php (limited to 'inc/lib/Twig/Node/Expression/Name.php') diff --git a/inc/lib/Twig/Node/Expression/Name.php b/inc/lib/Twig/Node/Expression/Name.php new file mode 100644 index 00000000..fceda2b7 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Name.php @@ -0,0 +1,41 @@ + $name), $lineno); + } + + public function compile(Twig_Compiler $compiler) + { + static $specialVars = array( + '_self' => '$this', + '_context' => '$context', + '_charset' => '$this->env->getCharset()', + ); + + $name = $this->getAttribute('name'); + + if ($this->hasAttribute('is_defined_test')) { + if (isset($specialVars[$name])) { + $compiler->repr(true); + } else { + $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); + } + } elseif (isset($specialVars[$name])) { + $compiler->raw($specialVars[$name]); + } else { + $compiler->raw(sprintf('$this->getContext($context, \'%s\')', $name)); + } + } +} -- cgit v1.3