Explorar o código

[Templating] fixed misnamed variable that caused some double-rendering problems

Fabien Potencier %!s(int64=15) %!d(string=hai) anos
pai
achega
3ec9005680

+ 4 - 4
src/Symfony/Components/Templating/Engine.php

@@ -82,18 +82,18 @@ class Engine
     public function render($name, array $parameters = array())
     {
         if (isset($this->cache[$name])) {
-            list($name, $options, $template) = $this->cache[$name];
+            list($tpl, $options, $template) = $this->cache[$name];
         } else {
-            list($name, $options) = $this->splitTemplateName($old = $name);
+            list($tpl, $options) = $this->splitTemplateName($name);
 
             // load
-            $template = $this->loader->load($name, $options);
+            $template = $this->loader->load($tpl, $options);
 
             if (false === $template) {
                 throw new \InvalidArgumentException(sprintf('The template "%s" does not exist (renderer: %s).', $name, $options['renderer']));
             }
 
-            $this->cache[$old] = array($name, $options, $template);
+            $this->cache[$name] = array($tpl, $options, $template);
         }
 
         $this->current = $name;

+ 1 - 1
tests/Symfony/Tests/Components/Templating/EngineTest.php

@@ -99,7 +99,7 @@ class EngineTest extends \PHPUnit_Framework_TestCase
             $this->fail('->render() throws an InvalidArgumentException if no renderer is registered for the given renderer');
         } catch (\Exception $e) {
             $this->assertInstanceOf('\InvalidArgumentException', $e, '->render() throws an InvalidArgumentException if no renderer is registered for the given renderer');
-            $this->assertEquals('The template "foo" does not exist (renderer: name).', $e->getMessage(), '->render() throws an InvalidArgumentException if no renderer is registered for the given renderer');
+            $this->assertEquals('The template "foo:name" does not exist (renderer: name).', $e->getMessage(), '->render() throws an InvalidArgumentException if no renderer is registered for the given renderer');
         }
 
         $engine = new ProjectTemplateEngine(self::$loader, array(), array(new SlotsHelper()));