DIV is a helper class, as explained here: 
http://web2py.com/book/default/chapter/05#HTML-Helpers. It takes arguments 
-- you cannot insert arbitrary Python code within its argument list. Stick 
with your first version.

On Sunday, April 10, 2011 8:09:14 PM UTC-4, 黄祥 wrote:

> hi, 
>
> is it possible to using div using the web2py format that contain 
> looping and if else condition? 
> i found an error during convert my view : 
>
> from: 
>
> <DIV id = 'leftbar'> 
> {{=H1(title)}} 
> {{for i, row in enumerate(rows):}} 
> {{if i == items_per_page: break}} 
> {{=A(T(row.title), _href = URL("blog_show", args = row.id), _title = 
> T(row.title))}} 
> {{=BR()}} 
> {{pass}} 
> {{if page:}} 
> {{=A(T('Previous'), _href = URL(args = [page - 1]), _title = 
> T('Previous'))}} 
> {{pass}} 
> {{if len(rows) > items_per_page:}} 
> {{=A(T('Next'), _href = URL(args = [page + 1]), _title = T('Next'))}} 
> {{pass}} 
> </DIV> 
>
> into : 
>
> {{=DIV(H1(title), 
> for i, row in enumerate(rows): 
> if i == items_per_page: break 
> A(T(row.title), _href = URL("blog_show", args = row.id), _title = 
> T(row.title)), 
> BR(), 
> pass 
> if page: 
> A(T('Previous'), _href = URL(args = [page - 1]), _title = 
> T('Previous')), 
> pass 
> if len(rows) > items_per_page: 
> A(T('Next'), _href = URL(args = [page + 1]), _title = T('Next')), 
> pass 
> ), _id = 'leftbar'}} 
>
> i know i'm wrong, please explain and show my fault, please 
>
> thank you so much

Reply via email to