I need to include the contents of a file (inside my resources folder) inside a Twig template.
I have tried this with no luck:
{% include \'public/directo
You can solve this problem with twig extension functions. ( http://symfony.com/doc/current/cookbook/templating/twig_extension.html )
Create a php file in your Bundle for the Twig extension
Add this code to the app/config/services.yml
app.twig_extension:
class: AppBundle\Twig\AppExtension
public: false
tags:
- { name: twig.extension }
Now you can use your custom function as any default function in your twig template
{{ fileGetContents( asset("uploads/my_text_file.txt") ) }}