Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.
https://shopify.github.io/liquid/
MIT License
11.1k stars 1.39k forks source link

Prevent escaping HTML tags inside variable #1490

Open DanielStout5 opened 2 years ago

DanielStout5 commented 2 years ago

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?

csaundersz commented 2 years ago

Also looking for unescape.

csaundersz commented 2 years ago

Would Shopify take a PR to support unescapeas 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

jason-engage commented 1 year ago

unescape would be great! so easy to implement too

diegovogel commented 2 months ago

I'd love to have this as well. Is someone working on it?

In my case, in section settings I want to include some <span> elements in a richtext field to add some styling. I can use a textarea field instead, but then everything needs to be handwritten (bold, italics, links, etc).