Problem/Motivation
Rendering content from paragraph.field.value|raw do not render entity embed properly.
Steps to reproduce
When I tried to render a view block or a custom block inside the tabs entity embed buttons on WYSIWYG, it did not render.
Install entity embed and views entity embed
Create an entity embed button to allow add custom block or a view.
Add a ixm blocks tabs to layout builder and try the ixm accordion block.
Proposed resolution
I have 4 proposed solutions:
1. Replace this: {{ item['#paragraph'].field_body.value|raw }}
Over this:
{% if item['#paragraph'].field_body %}
{% set format = 'full_html' %}
{% if item['#paragraph'].field_body.getValue()[0] %}
{% set format = item['#paragraph'].field_body.getValue()[0].format %}
{% endif %}
{% set field_body = {
'#text': item['#paragraph'].field_body.value|raw,
'#type': 'processed_text',
'#format': format,
} %}
{{ field_body }}
{% endif %}
2. Create a twig filter to render the field.
3. Use twig_tweak as dependency and use view filter, replacing this: {{ item['#paragraph'].field_body.value|raw }}
Over this: {{ item['#paragraph'].field_body|view }}
3. Hook preprocess the block to generate rendered content for the field and use that directly on the template.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3294399-twig-tweak-render-richtext-field.patch | 1.39 KB | aurora.luzzardi |
| #3 | 3294399-render-richtext-field.patch | 1.34 KB | aurora.luzzardi |
Issue fork ixm_blocks-3294399
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 #2
aurora.luzzardiComment #3
aurora.luzzardiI created a patch for solution 1, here is the patch:
Comment #4
aurora.luzzardiI created a patch for solution 3.
Comment #5
aaronchristian commentedAwesome thanks @aluzzardi,
I think the twig tweak approach is cleaner, going to implement that patch as the fix moving forward.
Thanks for the contribution!
Comment #6
aaronchristian commentedComment #9
aaronchristian commentedComment #10
aaronchristian commented