Problem/Motivation
According to documentation, we can use hyphens (-) in pattern ids :
id
The root of a new pattern definition (blockquote in the example above). It must contain only lowercase characters, numbers, underscores and hyphens (i.e. it should validate against [^a-z0-9_-]+).
Cf https://www.drupal.org/docs/contributed-modules/ui-patterns/define-your-...
However, when naming a pattern for example "collapsible-language", if we create a Twig file dedicated to a preview or a variant (ex : pattern-collapsible-language--preview.html.twig), this Twig file is not taken into account in the pattern library.
It's the base Twig file that is used.
It seems there is an error handling theme suggestions when using hyphens in pattern names : see attached screenshot.
If we replace the hyphen by an underscore in pattern id and file names, everything works well.
We detected this issue in 1.x, but maybe it impacts 2.x as well.
| Comment | File | Size | Author |
|---|---|---|---|
| Capture d’écran du 2024-12-17 16-04-14.png | 90.72 KB | mh_nichts |
Comments
Comment #2
pdureau commentedThere are no variant specific or preview specific templates in UI Patterns 2
Comment #3
mh_nichtsThanks for the feedback.
Nevertheless, I think the fix is worth being handled for v1 : to be able to use hyphens in patterns id, and preview/variant templates would be correctly used.
Comment #4
mh_nichtsThis issue affects also the preprocess naming : it works only with underscores (not possible to use hyphens).
I guess it's more a documentation issue then : it shouldn't be allowed to use hyphens in a pattern id ?
Comment #5
grimreaperHi,
Documentation page updated to no more mention hyphens.
Comment #7
grimreaper