The template name and the line are reported as part of the message, not as part of the exception location, as done for most other Twig errors (and so the Symfony error page would not extract a code snippet from the Twig file).
The cause is that the location is set by using \Twig\Template::loadTemplate in the compile code (see the compilation logic) but that method takes only a template name, not a source context. And when it builds a source context from it, it cannot give it a source path, even if the template had the info.
A suggestion to fix that would be to change \Twig\Template::loadTemplate to accept a SourceContext rather than a template name (we might support both if needed) for cases which have it (most places now, as the compiled code always extract the name from the source context anyway).
See the fiddle at https://twigfiddle.com/hmgy4z
The template name and the line are reported as part of the message, not as part of the exception location, as done for most other Twig errors (and so the Symfony error page would not extract a code snippet from the Twig file).
The cause is that the location is set by using
\Twig\Template::loadTemplate
in the compile code (see the compilation logic) but that method takes only a template name, not a source context. And when it builds a source context from it, it cannot give it a source path, even if the template had the info.A suggestion to fix that would be to change
\Twig\Template::loadTemplate
to accept a SourceContext rather than a template name (we might support both if needed) for cases which have it (most places now, as the compiled code always extract the name from the source context anyway).