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 that folder), and the view will be rendered in the current web2py environment. response.render() also takes a dictionary-like second argument to add variables to the environment, as well as keyword arguments to do the same. The gluon.template.render() function provides a little more flexibility to render in a different environment and to more easily point to templates and included files outside the usual /views folder (or to use template code stored in the database). Anthony On Friday, November 8, 2013 8:43:07 AM UTC-5, Niphlod wrote: > > 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 straight python & helpers, but a view seems so much >> more natural. >> >> - Scott >> > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.