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

Command icon 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

IT-Cru created an issue. See original summary.

sourabhsisodia_’s picture

Assigned: Unassigned » sourabhsisodia_

sourabhsisodia_’s picture

Assigned: sourabhsisodia_ » Unassigned
Status: Active » Needs review
sourojeetpaul’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new54.37 KB
new55.37 KB

Hello @sourabhsisodia_,
The changes look fine to me and it successfully resolves the issue. Hence moving it to RTBC++
Attaching screenshots for reference!

thejimbirch’s picture

Status: Reviewed & tested by the community » Fixed

Merged to dev, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.