This is not unique to web2py helpers or web2py in general. In Python, all 
positional arguments must come before any keyword arguments.

On Thursday, November 3, 2011 6:05:03 PM UTC-4, BrendanC wrote:
>
> HTML Helpers - Position Dependency Gotcha
>
> I'm posting this as it might help others and it took me a while to figure 
> out the cause of some syntax errors I was getting with the HTML helpers. 
> (In my case the problem surfaced in a much more complex statement so the 
> underlying problem was somewhat hidden). 
>
> I'm not sure if the docs point this out anywhere, but I ran into the 
> following problem:
> (You can easily test this in a Web2py shell - just do 'python web2py.py - 
> S appname -M' from a console)
>
> This does not work - gets python syntax error
>
>   str = DIV( _class='cls',  LI('aaa'))
>   str.xml()
>
> This works as expected:
>
>   str = DIV (LI('aaa'), _class='cls')
>   str.xml()
>
> It appears that the arguments in for HTML helpers are position dependent 
> and attributes need to be placed at the end. This caught be by surprise as 
> the with normal html the parameter position does not matter. 
>
> I'm not sure if Web2py has any 'troubleshooting' type documentation - but 
> this type of example could be a useful addition to the manual/docs/other.
>
> Hope this helps someone.
>
> BrendanC
>

Reply via email to