Validate the CSS categories in libraries.yml files.

Created on 8 December 2014, over 10 years ago
Updated 30 August 2023, over 1 year ago

Problem/Motivation

Let's add a new library definition:

drupal.node:
  version: VERSION
  css:
    css/node.module.css: {}

... this looks reasonable, but in fact this is broken. You need to specify a category:

drupal.node:
  version: VERSION
  css:
    layout:
      css/node.module.css: {}

This is far from being obvious.

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->

Proposed resolution

Add some validation code in LibraryParser.php to ensure the "category" is right.

In case you use a path as category, throw an exception like:

You have to key the css files in the "$module.library.yml" file by category (css/node.module.css seems is a filename, allowed categories are ...)

In case someone actually uses a category, throw an exception like:

You use an invalid category "invalid_cateogry" in "module.libraries.yml". Allowed categories are ...

An example for such a library.yml file would be:



drupal.node:
  version: VERSION
  css:
    invalid_category:
      css/node.module.css: {}

Remaining tasks

Fix tests that are not using categories.

User interface changes

API changes

πŸ“Œ Task
Status

Closed: outdated

Version

9.5

Component
Asset libraryΒ  β†’

Last updated 3 days ago

No maintainer
Created by

πŸ‡©πŸ‡ͺGermany dawehner

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024