Problem/Motivation
Stealing this idea from dawehner!
We are now using libraries for all CSS and JS. To add any of these libraries in a theme, they either have to be added site-wide or a theme needs to use a preprocess function to specify when they get added. It would be great if a themer had the ability to add a library directly from a template, to avoid creating preprocess functions (and using php.)
Proposed resolution
Add something, maybe a new function. Perhaps something like...
{%
set libraries = [
'special-css-library-1',
'special-js-library-1',
'some-library-we-know-is-defined-in-themename.libraries.yml',
]
%}
{{ add_libraries(libraries) }}
Remaining tasks
Discuss.
Agree.
Do.
Post change record.
Rejoice.
API changes
Adding a function would be an API addition.
Beta phase evaluation
Issue category | This is a feature because it is an api addition. |
---|---|
Issue priority | Normal because it is nice to have, but isn't preventing anything form working. |
Unfrozen changes | Unfrozen because it is an addition that should really only affect templates, which are not frozen. |
Prioritized changes | The main goal of this issue is to improve the themer experience. |
Disruption | This should not be very disruptive because it is an addition, so there are no backwards compatibility concerns. Besides the addition the only noticed change might be in core template files. |