Use Twig result as dynamic content in Icon

I’m trying to dynamically set the FA icon in a looper using the result of some Twig statements. If I put the {{looper.item}} in the Icon element’s regular text field, it’s fine and shows the correct string (ie ‘instagram’) but if I use it in the icon field with breakout mode it doesn’t set the icon as I was hoping. It works as expected if I set it up as an element parameter so there must be something about the Twig output and the icon field that I don’t quite understand.

Twig code:

{% set social = {‘facebook’:‘facebook-f’,‘instagram’:’’} %}
{% for key,value in social %}
{% if key in looper.item %}
{% set icon = value?:key %}
{{ icon }}{% endif %}{% endfor %}

Hey @TiDs,

Thanks for posting in! The issue could be caused by your incorrect quotes. You can try this:

{% set social = {
    'facebook': 'facebook-f',
    'instagram': ''
} %}

{% for key, value in social %}
    {% if key in looper.item %}
        {% set icon = value ?: key %}
        {{ icon }}
    {% endif %}
{% endfor %}

Be advised that custom coding is beyond the scope of our support under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One service for further assistance.

Best Regards.