Cannot extend Twig with country_name filter #1272
-
I'm trying to add support for the country_name filter in Twig. This will save a ton of work dealing with select boxes of country names and iso values. https://twig.symfony.com/doc/3.x/filters/country_name.html I've done: All good. In UF 5.1, I changed app/src/MyApp.php
In app/src/ServicesProvider/ I created TwigIntlExtensionService.php:
My twig template contains
That triggers a fatal error
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Have a look here : https://learn.userfrosting.com/templating-with-twig/filters-and-functions#extending-twig-extensions You can register the Twig Extension using the
And don't forget to add the |
Beta Was this translation helpful? Give feedback.
-
Thanks. So all I needed to do was the following in MyApp.php
|
Beta Was this translation helpful? Give feedback.
Have a look here : https://learn.userfrosting.com/templating-with-twig/filters-and-functions#extending-twig-extensions
You can register the Twig Extension using the
getTwigExtensions
method in your recipe instead of using a Service:And don't forget to add the
TwigExtensionRecipe
implementation in your recipe.