I don't think you can have conditional extend commands like that (extend and
include are not Python commands -- they are processed by the template engine
before the Python is run). You can have conditional include commands, but
technically all of the included views will be included and then
conditionally executed.
You might be able to do an extend with a variable (set in the controller and
passed to the view in the returned dict) in place of the view name, but in
that case, you will not be able to bytecode compile the views because the
compiler needs to know the extended view at compile time, but it won't
actually be determined until run time.
Anthony
On Monday, June 27, 2011 7:28:37 PM UTC-4, Luis Goncalves wrote:
> Hello!
>
> I need to customize my views so that they look good on a computer screen
> and on a smart phone.
>
> One way to do so, It think, is to have separate layout definitions and then
> do something like:
>
> {{if session.platform == 'mobile':}}
> {{extend 'mobile-layout.html}}
> {{else:}}
> {{extend 'desktop-layout.html'}}
> {{pass}}
>
> This does not seem to be working - I get lots of syntax errors (can't even
> figure out where they are!)
>
> Is this approach wrong? Is it possible to have a conditional "extend" ?
>
> Is there a smarter/better way to make the view rendering platform
> dependent?
>
> Thanks,
> Luis.
>