Twig will complain when downloading a file if it is not a valid branch template. The reason is that Twig will include the render file rather than its contents (found here ).
You can try with the use statement, but I don't think this will work.
Also, the syntax you are using seems wrong. When I include (or use) another branch template, I use this syntax:
{% use "AcmeWebsiteBundle::include.html.twig" %}
And the include.html.twig file is in src\Acme\WebsiteBundle\Resources\views\include.html.twig . So, if your file is located in src\Acme\WebsiteBundle\Resources\public\directory\include.ext , you can try
{% use "AcmeWebsiteBundle::..\public\directory\include.ext" %}
If this does not work, you can transfer the file to the views folder. If this is not possible, you can install app\Resources\views\ and use the syntax:
{% use "::include.ext" %}
If the usage instruction does not work, which I'm afraid you can transfer your file to the branch template. I draw some simple JSON structures with a twig. That way, you can include the contents of file.ext in the branch template and then render it.
If all this fails, you will need to create a Twig extension that will add a new tag (something like content ) that will read the file and output its contents to your branch template.
{% content 'public/directory/file.ext' %} {
Hope this helps you include your file.
Respectfully,
Matt
source share