Problem/Motivation
Adapting #3255663: Replace TWIG render with is not empty checks for 5.0.x went a little bit wrong because it looks like all if not empty checks are based on content instead of paragraph object in TWIG files.
Example from templates/paragraph--default.html.twig
{# Prints div with classes, and content without Width and Background. #}
<div{{attributes.addClass(classes)}}>
<div class="paragraph__column"> {% if content.bp_header is not empty %}
<h2>{{ content.bp_header }}</h2>
{% endif %}
{{ content|without('bp_background', 'bp_header', 'bp_width', 'bp_margin', 'bp_padding') }}
</div>
</div>
The content objects always include some information for rendering so this if not empty check doesn't work properly and for example empty H2 tags for content.bp_header gets rendered when there is not data in bp_header field of this paragraph.
Steps to reproduce
Create a simple BP paragraph without filling out header field and check rendered paragraph for empty h2-tag from this created paragraph.
Proposed resolution
Replace all TWIG {% if content.<bp_field> is not empty %} check with {% if paragraph.<bp_field> is not empty %} and also check if they could be simplified without accessing stuff like bp_accordion_expand['#items'].getString() in TWIG if statement.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screenshot from 2024-07-18 15-14-09.png | 55.37 KB | sourojeetpaul |
| #7 | Screenshot from 2024-07-18 15-13-07.png | 54.37 KB | sourojeetpaul |
Issue fork bootstrap_paragraphs-3447314
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
sourabhsisodia_ commentedComment #6
sourabhsisodia_ commentedComment #7
sourojeetpaul commentedHello @sourabhsisodia_,
The changes look fine to me and it successfully resolves the issue. Hence moving it to RTBC++
Attaching screenshots for reference!
Comment #8
thejimbirch commentedMerged to dev, thanks!