render_template是模板渲染,例如在开发flask项目中,我们会有一个templates文件夹,里面存放一些html文件,这些文件会在视图函数中被渲染,此时就会用到render_template包,如
而template_rendered是Flask的核心信号,当一个模板成功的渲染,这个信号会被发送,。这个信号与模板实例template和上下文的词典(名为context)一起调用
例如信号发送:
def _render(template, context, app):
"""Renders the template and fires the signal"""
rv = template.render(context)
template_rendered.send(app, template=template, context=context)
return rv