>
> response.subtitle = T('Aggregator for')+A('Company', _href='
> http://company.org/')
>
 
In the views, all strings are automatically escaped (unless wrapped in XML()). 
web2py HTML helpers are not escaped. However, the above concatenates a T() 
object with a helper -- the result of that concatenation is actually a 
string (i.e., the concatenation causes the A() helper to be serialized to a 
string before being added to "Aggregator for"). If you want to combine 
multiple items and still keep them wrapped in a helper so they are not 
serialized to a string, but you don't want a surrounding HTML tag, you can 
use the CAT() helper:

response.title = CAT(T('Aggregator for'), A('Company', _href=
'http://company.org/'))

Below, you can see that this results in a helper object, not a string, so 
it won't be escaped when inserted in the view:

>>> CAT(T('Aggregator for'), A('Company', _href='http://company.org/'))
<gluon.html.CAT object at 0x3356050>

And here's what you get when the view serializes the CAT() helper (notice 
no surrounding tag):

>>> CAT(T('Aggregator for'), A('Company', _href='http://company.org/')).xml
()
'Aggregator for<a href="http://company.org/";>Company</a>'

Anthony

-- 



Reply via email to