def _render(template, context, app): """Renders the template and fires the signal""" try: rv = template.render(**context) template_rendered.send(app, template=template, context=context) return rv except: print exceptions.text_error_template().render() raise
def _render(template: Template, context, app: flask.Flask): """Renders the template and fires the signal""" context.update(app.jinja_env.globals) app.update_template_context(context) try: rv = template.render(**context) template_rendered.send(app, template=template, context=context) return rv except: raise
def _render(template, context, app): """Renders the template and fires the signal""" app.update_template_context(context) try: rv = template.render(**context) template_rendered.send(app, template=template, context=context) return rv except: translated = TemplateError(template) raise translated
def _render(template, context, app): """Renders the template and fires the signal""" app.update_template_context(context) try: rv = template.render_unicode(**context) template_rendered.send(app, template=template, context=context) return rv except: translated = TemplateError(template) raise translated
def _render(template, context, app): """Renders the template and fires the signal""" context.update(app.jinja_env.globals) app.update_template_context(context) try: rv = template.render(**context) template_rendered.send(app, template=template, context=context) return rv except: from mako import exceptions return exceptions.html_error_template().render()
def _render(template, context, app): """Renders the template and fires the signal""" app.update_template_context(context) try: rv = template.render(**context) template_rendered.send(app, template=template, context=context) return rv except: translate = app.config.get("MAKO_TRANSLATE_EXCEPTIONS") if translate: translated = TemplateError(template) raise translated else: raise
def render(self, template_name, **kwargs): """ Render the given template with standard Flask parameters in addition to the specified template `kwargs`. """ template = self.lookup.get_template(template_name) try: args = {'url_for': url_for, 'get_flashed_messages': get_flashed_messages} args.update(kwargs) self.app.update_template_context(args) rv = template.render(**args) template_rendered.send(self.app, template=template, context=args) return rv except: raise TemplateError(template_name)
def render_template(template_name=None, context=None, format=None, **options): u"""Renders a Brevé template. :param template_name: as in `flask.render_template` but *without extension*. :param context: a dict of context variables :param **options: passed on to `breve.Template`. """ app = flask.current_app if context is None: context = {} app.update_template_context(context) bi = app.breve_instance for k, v in bi.options.iteritems(): options.setdefault(k, v) template = breve.Template(**options) rt = template.render(template_name, vars=context, loader=bi.template_loader, format=format) template_rendered.send(app, template=template, context=context) return rt