Hmm, it's been a long long time since I read the doc about the views.
But I don't recall reading about this behavior. I will have to go back
and take a look again. On the surface of it, forbidding inline
comments does not seem like a useful behavior when used within the
{{ }}. As in this case, I have been known to write functions in models
that end up migrating back into views for clarity's sake. For a
comment to cause this kind of problem seems somewhat user hostile. The
ticket wasn't too clear about the mistake, either.


On Mar 8, 6:22 pm, Bruno Rocha <[email protected]> wrote:
> thats not a bug, thats the behavior of template system. You can have
> comments only as first character on a line.
>
> allowed
>
> {{#comment}}
>
> disallowed
> {{=foo  # this will print foo }}
>
> as far as I remember, if I am not wrong... this has a good purpose and it
> is related of the literal '#' character.
>
> you can try using two hashes, but I am not sure. (I am on mobile and I cant
> test now)
>
> {{="foo" ##this prints foo}}
>
> http://zerp.ly/rochacbruno
> Em 08/03/2012 06:53, "weheh" <[email protected]> escreveu:
>
>
>
>
>
>
>
> > this works when placed inside a view:
>
> > {{
> > def myfunc(rows):
> >    text=[]
> >    for x in rows:
> >        text.append(...stuff...)
> >    pass
> > pass
> > }}
>
> > this gets ticketed when inside a view:
> > {{
> > def myfunc(rows):
> >    text=[]
> >    for x in rows:  # AN INNOCENT COMMENT THAT CAUSES TICKET
> >        text.append(...stuff...)
> >    pass
> > pass
> > }}
>
> > Traceback (most recent call last):
> >  File "N:\web2py\gluon\restricted.py", line 203, in restricted
> >    ccode = compile2(code,layer)
> >  File "N:\web2py\gluon\restricted.py", line 189, in compile2
> >    return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> > 'exec')
> >  File "N:\web2py\applications\myapp\views\myview/index.load", line 54
> >    text.append(
> >       ^
> > IndentationError: expected an indented block

Reply via email to