Reputation: 120
Im trying to append the name of the variable in img alt attribute, from the official documentation, they're hard-code the alt text.
is there any working solution?
{% for product in products %}
{{ product | img_tag: 'Picture of {{ product.name }}' }}
{% endfor %}
Thank you
Upvotes: 0
Views: 559
Reputation: 12933
You must do your logic outside and pass it as a variable.
{% for product in products %}
{%- capture image_alt -%}Picture of {{ product.title }}{%- endcapture -%}
{{ product | img_tag: image_alt }}
{% endfor %}
And there is no product.name
object but there is product.title
.
Upvotes: 1