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/directory/file.ext' %}
Isn't Twig capable of this? (I don't want to use Assetic)
3. raw. By default, everything in Twig gets escaped when automatic escaping is enabled. If you don't want to escape a variable you'll have to explicitly mark it as safe which you can do by using the raw filter.
You can get the current URL in Twig/Silex 2 like this: global. request. attributes. get('_route') .
New in version 1.15: The source function was added in Twig 1.15. The source function returns the content of a template without rendering it
http://twig.sensiolabs.org/doc/functions/source.html
I made a bundle just for this some time ago. It's pretty much a wrapper for file_get_contents
.
The setup can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With