ui_patterns icon indicating copy to clipboard operation
ui_patterns copied to clipboard

Use Drupal's theme keys inheritance

Open DuaelFr opened this issue 7 years ago • 2 comments

Long story short. \Drupal\ui_patterns\Definition\PatternDefinition::PATTERN_PREFIX should be "pattern__" instead of "pattern_" to allow to make leverage of the theme keys inheritance. It would allow to use a theme_preprocess_pattern that would apply on all patterns.

If you don't want people to change their template names to "pattern--my-pattern.html.twig" you can still force the template name in the hook_theme() call but I think it should be the new default (that you can make overridable in the pattern definition to keep future compatibility for PatternLab and Fractal).

DuaelFr avatar Aug 10 '18 14:08 DuaelFr

This has quite some implications, also related to work that @aleksip is doing on derivatives. I considered doing this at the beginning but then I realized that each pattern is really a different theme function, just prefixed by pattern_ for namespacing sake.

We can still add a global HOOK_preprocess_pattern() preprocess by using theme suggestions.

ademarco avatar Nov 18 '18 09:11 ademarco

I'm not sure that it is going to have the same result. I can't find the time right now to make some tests but it could really be interesting because I believe that when using pattern__foo theme key, both hook_preprocess_pattern and hook_preprocess_pattern__foo are called, unlike when using template suggestions.

Do you know if I'm right or would you have some time to try this out?

DuaelFr avatar Nov 19 '18 10:11 DuaelFr