In previous versions of Symfony2, to enable a extension you needed to add the Text and/or Debug extensions to an "extensions" array in your config.yml
//app/config/config.yml
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
extensions:
- twig.extension.debug
- twig.extension.text
This was because the extensions were added to the twig.xml file
//vendor/symfony/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
...
<service id="twig.extension.text" class="Twig_Extensions_Extension_Text" public="false">
<service id="twig.extension.debug" class="Twig_Extensions_Extension_Debug" public="false">
...
But, this is the way to do it now :
// app/config/config.yml
...
services:
twig.extension.text:
class: Twig_Extensions_Extension_Text
tags:
- { name: twig.extension }
I spent some time trying to figure out how to do it, so I hope it helps someone.
13 comments:
Thank you, you enlightened my day.
Thank you so much !
Thanks you helped me too!
FUCK YEAH AS WELL! Thanks!!!
Thats cool. I just wanted to know how you truncate content with html tags and prevent mayhem on the webpage.
{{ newsarticle.content | truncate(200) | raw }}
Thx a lot man :-)
Thank you, thank you, thank you! You saved my day.
Thanks a million, mate. You saved me a couple of hours
thanks you helped me too ^_^
thank you very much!!!!
works like a charm indeed!
Great, + ;)
thx!
Post a Comment