crodas / Haanga

Template compiler for PHP, Django-style (as much as possible). Pretty efficent by avoiding to have anything at run-time.
http://haanga.org/
Other
136 stars 28 forks source link

'Default' filter ignores autoescaping setting? #11

Closed martinml closed 10 years ago

martinml commented 12 years ago

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?

crodas commented 12 years ago

Thanks for the bug report, I'll work on a now. I'll push a fix tomorrow probably.