I think you mean the response object. The example code you gave still
use the character "<" so it does not help.

In fact, the problem is that web2py is not processing the xml document
but it parse directly the html file. I would really like Massimo to
fix this.

On Mar 12, 2:15 pm, Jonathan Lundell <[email protected]> wrote:
> On Mar 12, 2011, at 11:05 AM, pierreth wrote:
>
>
>
>
>
> > Hello,
>
> > I have small problem when the characters "< and ">" are used in web2py
> > html template views. Using them for Python breaks the html:
>
> > {{="OK" if x < 0 else "bad"}}
>
> > Because these characters are not escaped in the code, the html file is
> > no longer well formed.
>
> > Using the html entities "&lt;" and "&gr;" does not solve the problem
> > because web2py gives an error when theses characters are used as
> > Python code in templates.
>
> > Is it possible to fix this to have well formed html for web2py
> > templates?
>
> This is a consequence of the way the '=' (request.write) operator behaves at 
> the beginning of a code block: it treats the entire string as its argument 
> string, something like: request.write('"OK" if x < 0 else "bad"')
>
> You can rewrite it to use request.write explicitly, or to put each = operator 
> on its own line.
>
> {{request.write("OK" if x < 0 else "bad")}}
>
> or
>
> {{if x < 0:
> ="OK"
> else:
> ="bad"
> pass
>
> }}
>
> (I think)
>
> When the '=' operator is embedded in a code block, it consumes everything 
> until the end of the physical line or code block, whichever comes first. When 
> it begins a code block, it consumes the entire block.

Reply via email to