Reputation: 11
Background:
I am creating my first applications in Symfony and have encountered a problem that I can't seem to get past. Going forward the application that I'm creating will be the template which I will copy to create my next application - so the more in the global configuration the better from my perspective.
The question: Ideally I want my base.html.twig file to include a /css/style.css and /js/scripts.js from the Resources/public folder in the specific bundle being used. How do I do this? (Code snippets please!)
I have tried many other ways (guessing that the above wasn't possible) including block inheritance / overwriting and that has worked for the stylesheet (albeit I have to hard code the bundle name into the dependency name, which sucks).
The plan with this application is that I should be able to clone it under a new name and get going straight away, minimizing how much find & replace I have to do.
Thank you!
Upvotes: 0
Views: 78
Reputation: 2495
Please see the docs
Javascript files
{% javascripts '@AcmeFooBundle/Resources/public/js/*' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
CSS files
{% stylesheets 'bundles/acme_foo/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
Upvotes: 1