html - Raw twig variable filter within a short if -


i using short conditional discriminate values ​​displayed in list of records.

for example if want name of customers have greater 100 identifier emphasized (<em> </em>) perform following:

{# displays identifier of client #} {% set strclient = '<em>' ~ client.name ~ '</em>' %} {{ client.id > 100 ? strclient|raw : client.name }} 

here html processed browser , customer name displayed emphasized, fact if example want show phone, can null or not, , if no display message emphasized; perform following:

{# displays customer phone or message if there #} {{ client.id > 100 ? client.tel : '<em> not found </em>' }} 

in latter case html tags not processed browser , displayed plain text, i tried following:

{# displays customer phone or message if there #} {{ client.id > 100 ? client.tel : '<em> not found </em>'|raw }} 

and one:

{# displays customer phone or message if there #} {% set strclient = '<em> not found </em>' %} {{ client.id > 100 ? client.tel : strclient|raw }} 

with same result, ie when string, stored in variable or not html tags always appear if processed plaintext.

does know how html string in twig interpreted?

when using raw filter tenary if need wrap whole statement in brackets work.

e.g. {{ (client.id > 100 ? client.tel : '<em> not found </em>')|raw }}


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -