Problem/Motivation
Libraries are not attached to rendered media tokens.
Steps to reproduce
- Install Drupal 11 standard profile
- Install modules patternkit_example, patternkit_media_library, layout_builder
- Configure a content type to use Layout Builder
- On /admin/config/development/settings, enable "Do not cache markup" and "Twig development mode" (this makes debugging easier)
- On /admin/config/development/performance, disable CSS aggregation (this makes verifying easier in the final step)
- Create a node. On that node's Layout tab, insert block of type "[Patternkit] Media image embed".
- Select an image for that block (or upload new one).
- Save the layout.
- Inspect the image element. Notice that the Twig template rendering that image is core/modules/system/templates/image.html.twig
- Edit that Twig template. Add this line, to attach a new Claro library: {{ attach_library('claro/form-two-columns') }}
- Reload the node's page.
- Inspect the page source. Expect to find reference to core/themes/claro/css/layout/form-two-columns.css. However, you won't see it because Patternkit's media processor does not allow attachments to "bubble up" to the render system.
Proposed resolution
See MR https://git.drupalcode.org/project/patternkit/-/merge_requests/154.
When applied, you should see the attached library's assets in the page source (e.g., form-two-columns.css from the above example).
Remaining tasks
Write tests?
User interface changes
None
API changes
None
Data model changes
None
Issue fork patternkit-3526079
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
krisahil commentedComment #5
sluceroComment #6
johnle commentedReviewed, MR looks good.
Comment #8
slucero@krisahil, would you be able to re-test this and confirm it's working for you? Both myself and @minsharm have tested this according to the outlined testing instructions and were not able to see the library assets added to the page.
I also did some further debugging digging into the renderer debug settings to output attachments as well and was not seeing it getting added successfully. This was the case when I tested in both Drupal 10 and 11.
Comment #9
krisahil commented