crodas/Haanga — Issue #11: 'Default' filter disables autoescaping
Author: martinml
Created: 2011-10-15 19:17:26+00:00
State: open

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 snipped 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?