I try to load a simple base.html.twig template file that was moved from symfony’s default location app/Resources/views/ to the custom location theme/.
The template file contains:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
Extending the above template file by the controller Acme\Core\CoreBundle\Controller by using the controller-specific template
{% extends '::base.html.twig' %}
{% block body %}
Hello world!
{% endblock %}
leads to an error saying Unable to find template "::base.html.twig" in "AcmeCoreCoreBundle:Default:index.html.twig"..
How is it possible to tell symfony where to find the template files in global space?
Thanks in advance.
Due to Adam’s hint I am able to answer the question on my own. So I want to provide my answer if anybody is interested in.
The
AcmeDemoBundleprovides a twig extension (classAcme\DemoBundle\Twig\Extension\DemoExtension) that you simply can use. Change the constructor toNow tell symfony to register the twig extension. Edit your
config.ymlfile (e.g.app/config/config.yml) and appendLast but not least change your extending twig file and remove the
::from your default template’s namespace:{% extends 'base.html.twig' %}.