Reputation: 65
I would like to inline svg icons with twig source function.
My icons are in bundle - AppBundle/Resources/public/img/icons/
How can I access this icons path with source() ?
Upvotes: 0
Views: 2151
Reputation: 682
This is not how you access your assets in twig. You first have to generate your assets in the web directory with the command. (If your using Symfony 2.8 or higher you first need to install AsseticBundle)
php bin/console assets:install --symlink (Symfony3)
or
php app/console assets:install --symlink (Symfony2)
The symlink option prevent from hard copies into the web directory.
Then in twig you can access it with:
<image src="{{ asset('bundles/app/img/icons/your_icon.svg') }}"/>
Upvotes: 1