Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295747

Add the ability to include a library directly from a template file

$
0
0

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

Reference: https://www.drupal.org/core/beta-changes
Issue categoryThis is a feature because it is an api addition.
Issue priorityNormal because it is nice to have, but isn't preventing anything form working.
Unfrozen changesUnfrozen because it is an addition that should really only affect templates, which are not frozen.
Prioritized changesThe main goal of this issue is to improve the themer experience.
DisruptionThis 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.

Viewing all articles
Browse latest Browse all 295747


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>