Handle hyphens in Twig template name for preview/variant

Created on 17 December 2024, about 1 month ago

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.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France mh_nichts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024