[web2py] Re: jquery mobile switch in view

2011-07-22 Thread Ross Peoples
I have been pondering this for quite a while, and the only way I can think 
of doing this, while retaining the bytecompile option is to wrap the 
layout.html file in a if/then statement, and checking for mobile browsers in 
a model somewhere.

So your model would have a variable called is_mobile that determines if the 
current request is from a mobile browser. Then your model would contain 
something like this:

if is_mobile and request.extension == 'html':
request.extension = 'mobile'

Then your layout.html would contain something like this:

{{if is_mobile:}}

{{else:}}

{{pass}}

Then you can make views regular and mobile views. Regular views having the 
.html extension, and mobile views having a .mobile extension.


[web2py] Re: jquery mobile switch in view

2011-07-22 Thread Anthony
On Friday, July 22, 2011 4:56:20 AM UTC-4, David Marko wrote: 
>
> The {{extend }} can use variable as parameter so you can, under ome 
> conditions, compute template name and store it into response object(you can 
> place such code in model)
> e.g.
> response.template="layoutjq.html" 
>
> ... and in a view use the following:
> {{extend response.template}}
>
 
The only caveat in this case is that you cannot then bytecode compile your 
views (because the value of response.template will not be known at compile 
time).
 
Anthony
 


[web2py] Re: jquery mobile switch in view

2011-07-22 Thread David Marko
The {{extend }} can use variable as parameter so you can, under ome 
conditions, compute template name and store it into response object(you can 
place such code in model)
e.g.
response.template="layoutjq.html" 

... and in a view use the following:
{{extend response.template}}