Problem/Motivation

Twig 3 does not use the inline conditional like:
{% for key, item in array if key|first != '#' %}
....

Steps to reproduce

Open layout builder and add some of this blocks you'll get error.
Error in layout builder

Proposed resolution

Use condition as an if statement.
Instead of
{% for key, item in array if key|first != '#' %}
Use
{% for key, item in array %}
{% if key|first != '#' %}
....

Issue fork ixm_blocks-3366333

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

tpzurdo created an issue. See original summary.

tpzurdo’s picture

tpzurdo’s picture

StatusFileSize
new10.96 KB
carolpettirossi’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new394.18 KB

I also faced this issue when I tried to create an Accordion Block.
Screenshot showing the issue while trying to add an accordion block

I applied patch #5, and it solved the issue.

hfernandes made their first commit to this issue’s fork.

hfernandes’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new103.34 KB
new87.43 KB

I noticed that with the `if`, the `loop.index` wasn't counting correctly, so I changed it to use the `filter` filter instead.

Here is one example, the first accordion item should be open by default. With the `if` approach, it wasn't. The item counter starts with 16.
If counter

Using `filter`, the first item is open and the counter is 1:
Filter counter

Moving it back to `Needs Review`.

aaronchristian’s picture

Version: 1.0.5 » 1.0.x-dev
Status: Needs review » Reviewed & tested by the community

Ahhh nice catch @ tpzurdo.

Thanks @carolpettirossi and @hfernandes, yep confirmed that this morning.

Thanks for the contributions back everyone.

Marking as RTBC, and I'll get this one merged into dev as well.

aaronchristian’s picture

Status: Reviewed & tested by the community » Fixed
aaronchristian’s picture

Status: Fixed » Closed (fixed)