简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM