Unfortunately, for now, you can't compile views with Python logic in the
{{extend}} statement (as the logic cannot be evaluated until runtime), and
compiling is currently all or nothing. A while back I had submitted a patch
to allow compilation to proceed even with some views failing, but it was
never applied (I just submitted an issue revisiting the idea).
As an alternative, you can create two views, each extending a different
layout. To avoid duplicating the main content of each view, you can put
that into a third template file and simply include it in each view:
index1.html:
{{extend 'layout1.html'}}
{{include 'default/index.html'}}
index2.html:
{{extend 'layout2.html'}}
{{include 'default/index.html'}}
Then put the main template content in index.html. In the controler, set
response.view to either index1.html or index2.html.
Anthony
On Sunday, September 27, 2015 at 5:49:46 PM UTC-4, Facundo Médica wrote:
>
> Here is the error:
> Exception: name 'layout' is not defined in default/index.html
>
> The problem might be that I define which layout use in the view from the
> controller.
> So in the controller I return the variable *layout* which can be
> "layout1.html" or "layout2.html". So in the view I have: {{extend layout}}.
>
> How can I get around this?
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.