I have an Attribute.text name "Cushion Modified" and i am passing the same dynamically
{% if attribute.name=="Shape" %} {% set image = 'image/catalog/Products/shapes/sample/' ~ attribute.text ~ '.png' %} {% endif %}
After executing it the image src looks like src="image/catalog/Products/shapes/sample/Cushion" modified.png=""
I want to make it like image/catalog/Products/shapes/sample/Cushionmodified.png
Any help
CodePudding user response:
Not sure if the template engine allows execution of PHP directly, in which case, you could just enter the code below, to remove all spaces from the attribute.text
.
{% if attribute.name=="Shape" %}
{% set image = 'image/catalog/Products/shapes/sample/' ~ str_replace(' ','',attribute.text) ~ '.png' %}
{% endif %}
CodePudding user response:
trim() function do it