Closed woldtwerk closed 3 years ago
UI Patterns handles this. Check https://ui-patterns.readthedocs.io/en/8.x-1.x/content/patterns-definition.html#expose-pattern-assets-as-libraries
If you don't use UI Patterns you have to add it your libraries.yml inside your theme.
I'm using ui patterns. I handled my libraries with "vanilla" UI Patterns in other projects. That's why I'm a bit confused, that it doesn't work. The libraries even show up in ui_patterns_info_alter hook.
The js file is at the right place, the compiled pattern definition looks correct. Can't think of anything custom that, would break library loading.
I have to do some digging.
I was expecting that using a pattern in layout builder behaves similarly to using the pattern() function. It doesn't do that though. I would hope the ui pattern docs would mention that.
That means you need to attach libraries manually when using patterns in layout builder.
E.g. with the attach_library function in twig.
{{ attach_library('ui_patterns/PATTERN_ID.LIBRARY_NAME') }}
sorry for the inconvenience and the quick response
Just to clarify the above.
Adding libraries to patterns in the yml does not automatically load them when using {{ pattern() }}. It only works when using your pattern via Patterns UI with fields, display suite, views etc etc. Good to have this note here - but this is a Patterns UI thing. I agree with the above and think this should work. I am not going to use any front-end pattern management and do it all in templates, and therefore need this to work. I am going to create a Feature Request over at Patterns UI.
This is just a request for some info.
What do you need to do to make drupal register libraries defined in patterns?
this is my yml:
I also have the literature-references.js in there. It get's compiled into the dist/behaviours correctly and I can also use it in storybook when imported in the index.js
How do I tell Drupal to pick it up?