php - Loading Twig extensions via TwigBridge in Laravel -
I want to use the truncate filter from the Twig-extensions package in Laravel via TwigBridge , But I am seeing this error:
is not present in the "truncate" filter "[template file]" [##] Tried to add Laravel / App / Config / Package / RCFO / Trivitz / Confiff.FIP extension to ARAR in many different ways, no one does the work.
'twig_extensions_extension_ext', and
function () {New Twig_Extensions_Extension_Text (); }, Composer has correctly installed the file, I was able to load it with a test file using the same auto-loader.
Well, I feel a little dumb, but we take advantage of it the most. It is very clear about how to enable extra twig extensions in Laravel.
TL; DR: extensions are configured in extensions.php , not config.php .
Composer
Get started here, use the compiler's CLI command requirement; Musician needs a twist / extension or add the following line to your composer.json file
"twig / extension": " 1.2.*@dev ", If you are a musician. If you modify JSO, make sure to run composer run so that the package is installed.
Configuring TwigBridge
To add twig extensions for twitterbreeze, add them to enabled in laurel Should /app/config/packages/rcrowe/twigbridge/extensions.php . No config.php . Even if there is an extension array in config.php and this is where everything is configured, this is not the case where the extension is enabled. It is written in the documentation of twigbridge, but it is easy to ignore it. I missed it many times
'enabled' = & gt; ['TwigBridge \ Extension \ Loader \ Facades', 'TwigBridge \ Extension \ Loader \ Filters', // ... 'Twig_Extensions_Extension_Text', // & lt; - Add it], References the documentation of TwigBridge to the config.php file but the configuration file is renamed to twig.php It's been a while ago. Artisan Config: publish rcrowe / twivbridge generate a fresh configuration with generated twig.php and extensions.php files - no config do. Php . I was using TweigBridges for a while, so I still had a split, maybe adding my confusion.
Extension Name
Each name can be found in the extension extension file - they are just the name of the class of train, until January 2015, their included The five extensions listed here include:
- Array -
Twig_Extensions_Extension_Array
Filter:Shuffle - Date -
Twig_Extensions_Extension_Date
Filter:time_diff - I18n -
Twig_Extensions_Extension_I18n
Filter:Tran - Intl -
Twig_Extensions_Extension_Intl
filter:localized date,localized number localizedcurrency - Text -
Twig_Extensions_Extension_Text
filter:truncate, < Code> wordwrap
Comments
Post a Comment