liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Prevent escaping HTML tags inside variable

Open DanielStout5 opened this issue 4 years ago • 4 comments

We have HTML inside an order attribute we'd like to output in a Liquid template in Shopify - specifically it's in order.attributes.

Just doing e.g. {{ order.attributes.myHtmlVariable }} is escaped - e.g. it outputs < and >

How do we make Liquid output the variable without escaping? I've tried {% raw %} but that only disables the processing of Liquid tags themselves.

It's possible Shopify automatically encodes the contents of order.attributes - in that case, how can we unescape the HTML when outputting?

DanielStout5 avatar Nov 19 '21 17:11 DanielStout5

Also looking for unescape.

csaundersz avatar Feb 25 '22 10:02 csaundersz

Would Shopify take a PR to support unescape as a filter? Looks pretty straightforward to add to https://github.com/Shopify/liquid/blob/master/lib/liquid/standardfilters.rb from https://docs.ruby-lang.org/en/2.2.0/CGI/Util.html

csaundersz avatar Feb 25 '22 10:02 csaundersz

unescape would be great! so easy to implement too

jason-engage avatar Nov 22 '22 10:11 jason-engage