Help about html helper composition

39 views
Skip to first unread message

António Ramos

unread,
Dec 6, 2016, 12:17:12 PM12/6/16
to web...@googlegroups.com
I have an error in the next code and cant see the problem.
I would appreciate some help here.
thanks


 {{for x in kpi:}}
 {{=DIV(DIV(H3("???"),P(x["waiting"]),_class="inner"),DIV(I(_class="fa fa-hourglass-end"),_class="icon"),A(T("Please wait..."),_class="small-box-footer"),_class="small-box bg-red"
 ,_id=x["kpi"],_onclick="web2py_component('{{=URL('kpi', x['kpi']+'.load')}}', target='{{=x['kpi']}}')")}}
 {{pass}}
 {{pass}}



Traceback (most recent call last):
File "/home/ramstein74/webapps/new2py/web2py/gluon/restricted.py", line 226, in restricted
ccode = compile2(code, layer)
File "/home/ramstein74/webapps/new2py/web2py/gluon/restricted.py", line 209, in compile2
return compile(code.rstrip().replace('\r\n', '\n') + '\n', layer, 'exec')
File "/home/ramstein74/webapps/new2py/web2py/applications/fileit/views/entities/list.html", line 379
,_id=x["kpi"],_onclick="web2py_component('{{=URL('kpi', x['kpi']+'.load'))
^
SyntaxError: EOL while scanning string literal

Dave S

unread,
Dec 6, 2016, 2:16:27 PM12/6/16
to web2py-users


On Tuesday, December 6, 2016 at 9:17:12 AM UTC-8, Ramos wrote:
I have an error in the next code and cant see the problem.
I would appreciate some help here.
thanks



Isn't your _onclick using the same quote (') for the middle-ish string and the inner string it encloses?

/dps

António Ramos

unread,
Dec 7, 2016, 4:43:32 AM12/7/16
to web...@googlegroups.com
that was my first atempt but i got

Traceback (most recent call last):
File "/home/ramstein74/webapps/new2py/web2py/gluon/restricted.py", line 226, in restricted
ccode = compile2(code, layer)
File "/home/ramstein74/webapps/new2py/web2py/gluon/restricted.py", line 209, in compile2
return compile(code.rstrip().replace('\r\n', '\n') + '\n', layer, 'exec'
)
File "/home/ramstein74/webapps/new2py/web2py/applications/fileit/views/default/user.html", line 320
,_id=x["kpi"],_onclick="web2py_component('{{=URL("kpi", x["kpi"]+".load"))
^
SyntaxError: invalid syntax

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

António Ramos

unread,
Dec 7, 2016, 5:51:45 AM12/7/16
to web...@googlegroups.com
cant understand why this does not work

 {{=DIV(DIV(H3("???"),P(x["waiting"]),_class="inner"),DIV(I(_class="fa fa-mouse-pointer"),_class="icon"),A(T("Please wait..."),_class="small-box-footer"),_class="small-box bg-red"
 ,_id=x["kpi"],_onclick="web2py_component('{{=URL('kpi','people.load')}}', target='people')")}}

    ,_id=x["kpi"],_onclick="web2py_component('{{=URL('kpi','people.load'))
^
SyntaxError: EOL while scanning string literal

but this works
 {{=DIV(DIV(H3("???"),P(x["waiting"]),_class="inner"),DIV(I(_class="fa fa-mouse-pointer"),_class="icon"),A(T("Please wait..."),_class="small-box-footer"),_class="small-box bg-red"
 ,_id=x["kpi"],_onclick="web2py_component('/fileit/kpi/people.load', target='people')")}}

António Ramos

unread,
Dec 7, 2016, 6:23:12 AM12/7/16
to web...@googlegroups.com
Solved it, dont know if its the best solution but fine by me :)

 {{url=URL('kpi',x['kpi']+'.load')}}
 {{click="web2py_component('{0}', target='{1}')".format(url,x['kpi']) }}
 {{=DIV(DIV(H3("???"),P(x["waiting"]),_class="inner"),DIV(I(_class="fa fa-mouse-pointer"),_class="icon"),A(T("click to update..."),_class="small-box-footer"),_class="small-box bg-red"
 ,_id=x["kpi"],_onclick=click)}}
Reply all
Reply to author
Forward
0 new messages