Empty modifiers added if modifiers are NULL

Created on 6 July 2020, over 4 years ago
Updated 20 January 2024, 10 months ago

I have following code:

{% set some_base_class = some_base_class|default('is-default') %}
<sometag {{ bem(some_base_class, some_modifiers, some_blockname) }}>somestuff</sometag>

. I embed this code in another component like {% embed "@atoms/somethings/something.twig" with { some_base_class: 'is-not-default' } %}.

What I expect:
<sometag class="is-not-default">somestuff</sometag>

What I get:
<sometag class="is-not-default is-not-default--">somestuff</sometag>

This is, I guess, due bem() accepting only arrays as arguments for modifiers and extra classes, but in twig, undefined variables are empty strings or null or I don't know what, but not empty arrays. I could of course write many lines of twig code like {% set some_modifiers = some_modifiers|default([]) %}, but it would be better if bem() function would check if passed modifiers and extra classes arguments are defined or not empty string.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡±πŸ‡»Latvia mansspams

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024