I am using short conditional to discriminate the values displayed in a list of records.
For example if I want the name of the customers who have a greater than 100 identifier are emphasized (<em> </em>
) perform the following:
{# Displays the identifier of the client #}
{% set strClient = '<em>' ~ client.name ~ '</em>' %}
{{ Client.id > 100 ? strClient|raw : client.name }}
Here the HTML is processed by the browser and customer name is displayed emphasized, the fact is that if for example you want to show your phone, which can be null or not, and if it is no display a message emphasized; I perform the following:
{# Displays the customer phone or message if there #}
{{ Client.id > 100 ? client.tel : '<em> Not found </em>' }}
In the latter case HTML tags are not processed by the browser and displayed as plain text, I also tried the following:
{# Displays the customer phone or message if there #}
{{ Client.id > 100 ? client.tel : '<em> Not found </em>'|raw }}
And this one:
{# Displays the customer phone or message if there #}
{% set strClient = '<em> Not found </em>' %}
{{ Client.id > 100 ? client.tel : strClient|raw }}
With the same result, ie when is a string, this stored in a variable or do not get the HTML tags that always appear as if it were processed plaintext.
Does anyone know how to get the HTML string in a twig be interpreted?