+++ /dev/null
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) 2009 Fabien Potencier
- * (c) 2010 Arnaud Le Blanc
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a local private variable.
- *
- * Such variables are not visible from templates.
- *
- * @package twig
- * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
- */
-class Twig_Node_Expression_AssignLocalName extends Twig_Node_Expression_LocalName
-{
-}
+++ /dev/null
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) 2009 Fabien Potencier
- * (c) 2010 Arnaud Le Blanc
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a local private variable.
- *
- * Such variables are not visible from templates.
- *
- * @package twig
- * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
- */
-class Twig_Node_Expression_LocalName extends Twig_Node_Expression
-{
- static protected $counter = 0;
-
- public function __construct($name = null, $lineno = null)
- {
- if (null === $name) {
- $uniq = self::$counter++;
- $name = '__'.$uniq;
- }
-
- parent::__construct(array(), array('name' => $name), $lineno);
- }
-
- public function compile($compiler)
- {
- $compiler->raw('$'.$this->getAttribute('name'));
- }
-}
-
{
public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
{
- parent::__construct($expr, new Twig_Node_Expression_AssignLocalName(null, $lineno), $lineno, $tag);
+ parent::__construct($expr, new Twig_Node_Expression_AssignName(str_replace('.', '_', uniqid('_imported_', true)), $lineno), $lineno, $tag);
}
}
public function addImportedFunction($alias, $name, Twig_Node_Expression $node)
{
- $this->importedFunctions[0][$alias] = array(
- 'name' => $name,
- 'node' => $node,
- );
+ $this->importedFunctions[0][$alias] = array('name' => $name, 'node' => $node);
}
public function getImportedFunction($alias)
{
- if (!isset($this->importedFunctions[0][$alias])) {
- return null;
+ foreach ($this->importedFunctions as $functions) {
+ if (isset($functions[$alias])) {
+ return $functions[$alias];
+ }
}
- return $this->importedFunctions[0][$alias];
}
public function pushLocalScope()
*/
public function parse(Twig_Token $token)
{
- $name = '_tmp'.rand(10000, 99999);
+ $name = str_replace('.', '_', uniqid('_tmp_', true));
$node = new Twig_Node_Expression_Name($name, $token->getLine());
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($node, $this->getTag());