Let's suppose that we have a variable called foo which contains hello "world". Haanga is configured with the default options (that means autoescape enabled), so this code...
{{ foo }}
... returns...
hello "world"
... which is correct.
Now we want to use the default filter, because for whatever reason foo may not exist, like this:
{{ foo | default: "oops" }}
Problem is that if foo exists, it won't be automatically escaped. I mean, the previous snippet will return this:
hello "world"
This caught me by surprise, since other filters (lower, upper, title, etc) don't do this. It can be workarounded by appending | escape to the variable, but it feels wrong, since I enabled autoescaping :)
Is this intended? Shouldn't the default filter be aware of the autoescape setting?
Let's suppose that we have a variable called
foo
which containshello "world"
. Haanga is configured with the default options (that means autoescape enabled), so this code...... returns...
... which is correct.
Now we want to use the
default
filter, because for whatever reasonfoo
may not exist, like this:Problem is that if
foo
exists, it won't be automatically escaped. I mean, the previous snippet will return this:This caught me by surprise, since other filters (
lower
,upper
,title
, etc) don't do this. It can be workarounded by appending| escape
to the variable, but it feels wrong, since I enabled autoescaping :)Is this intended? Shouldn't the
default
filter be aware of theautoescape
setting?