Open GoogleCodeExporter opened 8 years ago
I think you should be able to use
{foo|str|html}
now. That will convert the number to a string and them to html.
There might be some behavior change warranted -- I did tweak this in the Python
version I think.
(Although, you don't need to ever escape numbers in HTML... so leaving it out
altogether works too)
Original comment by andyc...@gmail.com
on 13 Jan 2012 at 10:03
Thank you. This works indeed, but this is mainly a problem when relying on the
default_formatter. I may have missed something in the documentation, but I
haven't seen a "post_formatter", which would be applied to anything, after any
specific formatter.
> Although, you don't need to ever escape numbers in HTML... so leaving it out
altogether works too
This works if I know in advance that it's going to be a number and not an
arbitrary string with some characters that need to be escaped.
I was considering using { default_formatter: 'html' } as a short-cut for
putting "|html" after each variable name.
If you don't know whether your data is { foo: 1 } or { foo: '<escape me>' }, at
the moment, it seems you have to put "|str|html" behind every variable
("str|html" doesn't work as a default formatter).
In addition, I would also like the flexibility to change the default_formatter
(admittedly, more as a "post-processor" formatter, which isn't what it's meant
for) independently of the template itself, depending on what the target output
would be. Even if I knew that foo was a number in advance, "foo|str" would
replace the default formatter, not apply it before passing it to the html
formatter.
(Ultimately, I think this is a bug in the HTML formatters because they expect a
string as an input, which numbers are not, despite being valid JSON tokens.)
Original comment by bharbu...@gmail.com
on 13 Jan 2012 at 10:37
Original issue reported on code.google.com by
bharbu...@gmail.com
on 13 Jan 2012 at 9:34