If statements in twig I've got the following card in my drupal installation, I've hidden unnecessary items for my question in the picture. 

What I want to achieve is the following:
I want the icon to change based on the taxonomy term showed besides the little icon (in this case, test). 



This is the code that generates the card:

{% if topic_type %}
  {% embed "node--teaser__field.html.twig" %}     
    {%- block field_icon -%} group {%- endblock -%}
    {%- block field_value -%} {{ topic_type }} {%- endblock -%}
  {% endembed %}
{% endif %}


I think it should look something like this but it gives me an error:

{% if topic_type %}
  {% embed "node--teaser__field.html.twig" %}     
    {% if topic_type == 'test' %}  
      {%- block field_icon -%} icon 1 {%- endblock -%}
    {% else %}
      {%- block field_icon -%} icon 2 {%- endblock -%}
    {% endif%}
    {%- block field_value -%} {{ topic_type }} {%- endblock -%}
  {% endembed %}
{% endif %}
Twig blocks are named control structures, you can't define them multiple times within the same scope. Either try to move the if statement inside one single block

{% if topic_type %}
  {% embed "node--teaser__field.html.twig" %}     
    {%- block field_icon -%}
      {% if topic_type == 'test' %}
        icon 1 
      {% else %}
        icon 2 
      {% endif%}
    {%- endblock -%}
    {%- block field_value -%} {{ topic_type }} {%- endblock -%}
  {% endembed %}
{% endif %}


or don't overwrite the block at all, instead use variables and pass them down in the embed statement

{% set custom_icon = (topic_type == 'test' ? 'icon1' : 'icon2') %}
{% embed "node--teaser__field.html.twig" with {'icon': custom_icon, 'title': topic_type } %}


I'd recommend the first when there are major overwrites in the HTML output, and the 2nd when only strings/variables/placeholders are replaced.