Manish Basdeo
Manish Basdeo

Reputation: 6269

How can I include a javascript file from inside my Bundle into a twig file?

How can I include a javascript file from my Bundle CompetitiongameBundle, in a twig file ? What does the asset function mean ?

Upvotes: 2

Views: 3541

Answers (1)

moonwave99
moonwave99

Reputation: 22817

Don't you trust symfony docs?

You can also include assets located in your bundles' Resources/public folder. You will need to run the php app/console assets:install target [--symlink] command, which moves (or symlinks) files into the correct location. (target is by default "web").

<link href="{{ asset('bundles/acmedemo/css/contact.css') }}" type="text/css" rel="stylesheet" />

I don't advice to you link against individual resources from bundle - use Assetic for that, possibly minifying them.

Upvotes: 4

Related Questions