Repeater field funkyness

Alright…

I have a module where the editor can add a checkmark list and a number of buttons to their liking. Both groups are repeaters:

{# List items, if any added #}
 {% if module.text.list_item %}
 <ul class="image-text__checklist checklist"> 
 {% for item in module.text.list_item %}
 <li>
 {# Icon #}
 <div class="image-text__checklist-checkmark checklist__checkmark">
 <svg class="image-text__checklist-icon checklist__icon checklist__icon--checkmark">
 <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#checkmark"></use>
 </svg>
 </div>
 {# Text #}
 <span>{{ item.value }}</span>
 </li>
 {% endfor %}
 </ul>
 {% endif %}
 {# Buttons, if any added #}
 {% if module.text.buttons %}
 <div class="image-text__buttons">
 {# Button loop #} 
 {% for button in module.text.buttons %} 
 <a href="{{ button.button.url.href }}" title="{{ button.title }}" class="btn{% if loop.index > 1 %} btn--ghost{% else %} btn--default{% endif %}{% if button.icon %} btn--icon{% endif %}{% if button.icon_reverse %} btn--icon-reverse{% endif %}{% if button.video_link %} js-btn--video btn--video{% endif %}" {% if button.video != "" %}data-video-url="{{ button.video }}"{% endif %}>
 {% if button.icon.src != '' %}
 <img src="{{ button.icon.src }}" alt="{{ button.icon.alt }}"> 
 {% endif %}
 <span>{{ button.title }}</span>
 </a>
 {% endfor %}
 </div>
 {% endif %}

This is the editor look:

And this is the output:

Adding two checkmark items adds 4 empty buttons in the UI :sweat_smile:
What’s going on?
I can fix it by adding a button in the UI and removing it again. But still, the two loops are hardly related, so i’m quite interested to see if anyone can figure out what’s happening - if it’s not a bug :slightly_smiling_face:

Hmm, that is indeed odd. When doing an if statement checking for a repeater field, I would check whether it’s iterable, rather than whether it exists e.g.

{% if module.text.buttons|length > 0 %}
..
{% endif %}

{# or #}

{% if module.text.buttons is iterable %}
..
{% endif %}

I learn something new every day with this wonderful platform. Thanks!
“is iterable” did indeed solve the issue. Don’t know if checking for existense is considered “wrong” in HubL, but if not, i’d say something fishy is going on.

I think the issue is that on the server the dict/object “module.text.buttons” exists, created by it being a repeater field, but is empty. What really matters is whether that object contains anything

Makes sense. Thanks for taking the time to elaborate. Much appreciated

Thnkas for taking a look, @piersg :raising_hands: