How do I escape HTML by default in Liquid?
Asked Answered
S

0

10

I know that it's possible to escape HTML in liquid by using the escape filter

# cthulhu is "<blink>blink</blink>"

{{ cthulhu || escape }}

but is it possible to make liquid escape the HTML in all variables by default?

I know that Rails escapes all HTML by default, but I have to use html_safe because otherwise all the HTML within the liquid template is escaped.

I only found this issue on GitHub, which told the OP to just ask on Stack Overflow.

Saad answered 24/1, 2017 at 23:40 Comment(2)
This still seems to be an issue in 2022. There is a "new" open issue which unfortunately has no answers or solutions.Dol
It looks like it uses a single pipe, not the bitwise 'or'? shopify.github.io/liquid/filters/escapeLeak

© 2022 - 2024 — McMap. All rights reserved.