Replies: 3 comments 2 replies
-
outputEscape is
You're missing
|
Beta Was this translation helpful? Give feedback.
-
Is there any solution to this? {{ foo }} // outputEscape is enabled That is because some filters like nl2br already escape the input. For now the only solution is to do: A way to solve this issue would be if it is possible for a filter to know which filters were called before itself? liquidjs/src/template/output.ts Line 16 in 1380ac9 |
Beta Was this translation helpful? Give feedback.
-
Hi @ybouane , I took this approach
And released this feature in v10.3.0, here's an example: liquidjs/test/integration/liquid/register-filters.ts Lines 53 to 62 in e6db371 |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm using the outputEscape option to escape output by default.
However, for some specific filters I want to disable the escaping, how can that be done?
How to integrate the functionality of the raw filter into my own filters. (I saw in the code that the raw filter is hardcoded :/ )
Example:
{{ "<b>Hello \nworld.</b>" }}
would output:
<b>hello world</b>
I made a nl2br filter:
const nl2br = function(str) {return escapeHtml(str).replace(/\r?\n/g, '<br>')};
So for:
{{ "<b>Hello \nworld.</b>" | nl2br }}
the output is:
&lt;b&gt;hello <br>world&lt;/b&gt;
(it escapes twice)
Whereas I actually want:
<b>hello <br>world</b>
The way to achieve that would be to type in
{{ "<b>Hello \nworld.</b>" | nl2br | raw }}
(and remove the escapeHtml step from the function), but I wanted to check if it was possible to avoid that?I tried storing a variable isEscaped in the context of the nl2br filter and checking if is set on my outputEscape function which works in a simple use-case but fails in this example:
{% assign "a" | nl2br %} {{ "<b>Hello \nworld.</b>" }}
In this case, the second statement skips the escaping which is undesirable.
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions