I'm using Tornado and have a html file that I want to use as the content for an email. The way i'm emailing is to use a os.system()
command. However I need to dynamically create a section of the html file. I have been reading about UI modules. I'm wondering if i can use the UI module to pass arguments to dynamically create a html page and then retrieve this as a string?
I've beem using the standard templates within my html to render pages in html. E.g.
class xxx(BaseHandler):
async def get(self):
self.render("xxx.html",
s=sss,
u=user,
p="somethingXXX")
I want to use the same template functionality however be able to retrieve the string? Is this possible?
You're looking for the RequestHandler.render_string
method. This is similar to render
, but it returns the string to the caller instead of writing it as the HTTP response.
UIModules
are different - they're a way of organizing things within your templates, with special features for javascript/css dependencies (and they only work with render
, not render_string
).