diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index fb4b728a5bede..d4b88be79755f 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -74,11 +74,11 @@ public function render($name, array $parameters = array()) if ($name instanceof TemplateReference) { try { // try to get the real name of the template where the error occurred - $name = $e->getTemplateName(); - $path = (string) $this->locator->locate($this->parser->parse($name)); if (method_exists($e, 'setSourceContext')) { - $e->setSourceContext(new \Twig_Source('', $name, $path)); + $e->setSourceContext($e->getSourceContext()); } else { + $templateName = $e->getTemplateName(); + $path = (string) $this->locator->locate($this->parser->parse($templateName)); $e->setTemplateName($path); } } catch (\Exception $e2) {