[web2py] Re: Use view to generate a string

2013-11-08 Thread Anthony
Good point. You can also use response.render(), which may be a bit simpler: mytext = cache.ram('mytext', lambda: response.render('path/to/template.html'), time_expire=3600) The path must be relative to the app's /views folder (you can use ../ to get out of t

[web2py] Re: Use view to generate a string

2013-11-08 Thread Anthony
You can use the render() function: import os from gluon.template import render mytext = cache.ram('mytext', lambda: render(filename=os.path.join(request.folder, 'path', 'to', 'template.html')), time_expire=3600) If the template contains any {{include ...}} d

[web2py] Re: Use view to generate a string

2013-11-08 Thread Niphlod
response.render is what you're seeking for ... On Friday, November 8, 2013 3:49:14 AM UTC+1, Scott Hunter wrote: > > Is it possible to use a view to generate a string? In this particular > case, I want to generate a snippet of HTML & cache it away. I suppose this > could be done using straigh

[web2py] Re: Use view to generate a string

2013-11-08 Thread Leonel Câmara
I think what you want is a controller with a cached view, if it is then, check the example in the book http://web2py.com/book/default/chapter/04#cache for cache/view. Of course that if you explain more thoroughly what you are trying to do, other options may be better. Sexta-feira, 8 de Novem