Trying to optimize a code to output a value based on multiple conditions

03/07/2018


Basically I have this if else condition that checks the entity type of a node and outputs a value based on the condition. As seen in the code below if the entity type is press_release it outputs Press Release on the markup and if the entity type is interview, it outputs Interview.

The problem with this is that once there are multiple conditions it becomes a hassle to maintain is there a way to shorten it?

{% for newsdesk in accordion.entity.field_newsdesk_and_press %}

    {% if article.entity.getType == 'press_release' %}

         <a href="#" >Press Release</a>

    {% endif %}


   {% if article.entity.getType == 'interview' %}

         <a href="#" >interview</a>

    {% endif %}

{% endfor %}

قالب وردپرس