Marek Fiala
Marek Fiala

Reputation: 65

Twig source function path

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

Answers (1)

OlivierC
OlivierC

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

Related Questions