Output raw html from if statement and combining strings? I have the following code:

&lt;img{{ block.imageWidth|length ? ' width="' ~ block.imageWidth ~ 'px"' }} /&gt;


If imageWidth is specified as 120, it should output:

&lt;img width="120px" /&gt;


However it is outputting this:

&lt;img width=&amp;quot;120px&amp;quot; /&gt;


I've tried using |raw but that doesn't work.

Any ideas?

Thanks
{# set test variable, to make your code work #}
{% set block = {imageWidth: 300} %}

{# the real output #}
&lt;img{{ block.imageWidth|length ? (' width="' ~ block.imageWidth~ 'px"')|raw }} /&gt;


Works for me