I'm building a /app/Resources/base.html.twig
with common features for almost all the development I have since for example all use Twitter Bootstrap, Select2 and some common libraries. Then for any project I created a bundle called TemplateBundle
and inside it I have a template called layout.html.twig
which extends from base.html.twig
. Having this as a start point I have some doubts around my approach:
-
In
base.html.twig
I handle assets with Assetic and I have this lines:{% block stylesheets %} {% stylesheets 'bundles/template/css/bootstrap.min.css' 'bundles/template/css/bootstrap-theme.min.css' 'bundles/template/css/font-awesome.min.css' 'bundles/template/css/select2.css' 'bundles/template/css/select2-bootstrap.css' 'bundles/template/css/bootstrapValidator.min.css' 'bundles/template/css/datepicker.css' 'bundles/template/css/datepicker3.css' 'bundles/template/css/styles.css' filter='cssrewrite' %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} {% endblock %}
I want to make base.html.twig
as extendable as can be and in the code above not all of my sites uses datepicker.css
or styles.css
since this are part of the current one or in other cases files names changed between sites, so my question regarding this is: how I handle this in layout.html.twig
? For example in Site1 all the templates will extends from layout.html.twig
and then in this layout I can set the use of datepicker
and styles
but for Site2 I could define to use just styles
and so on, so how to handle this in layout.html.twig
maintaining assetic?
- As you may notice all my assets resides on
TemplateBundle
but what happens if tomorrow I called this Template1Bundle? Then I should take care ofbase.html.twig
and change any assetic path, how do you handle this? I mean where do you put your common files as this one for example?
Understand my question?