Every line of 'render template in flask' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
52 def render_template(template, **context): 53 return Response(jinja_env.get_template(template).render(**context), mimetype='text/html')
22 def render_template(self, template_name, **kwargs): 23 values = {} 24 for f in app.get_context_processors(): 25 values.update(f(self)) 26 values.update(kwargs) 27 return render_template(template_name, **values)
61 def render(template, tmpl_vars=None, method=None): 62 """Generate a markup stream from the given template and vars. 63 64 :param template: A template path. 65 :param tmpl_vars: A dict of variables to pass into the template. 66 :param method: Optional serialization method for Genshi to use. 67 If None, we don't serialize the markup stream into a string. 68 Provide 'auto' to use the best guess. See :func:`render_stream`. 69 :rtype: :class:`genshi.Stream` or :class:`genshi.Markup` 70 :returns: An iterable markup stream, or a serialized markup string 71 if `method` was not None. 72 73 """ 74 if tmpl_vars is None: 75 tmpl_vars = {} 76 assert isinstance(tmpl_vars, dict), \ 77 'tmpl_vars must be a dict or None, given: %r' % tmpl_vars 78 79 tmpl_vars.update(tmpl_globals()) 80 81 # Pass in all the plugin templates that will manipulate this template 82 # The idea is that these paths should be somewhere in the 83 # top of the template file. 84 plugin_templates = app_globals.plugin_mgr.match_templates(template) 85 tmpl_vars['plugin_templates'] = plugin_templates 86 87 # Grab a template reference and apply the template context 88 if method == 'text': 89 tmpl = app_globals.genshi_loader.load(template, cls=NewTextTemplate) 90 else: 91 tmpl = app_globals.genshi_loader.load(template) 92 93 stream = tmpl.generate(**tmpl_vars) 94 95 if method is None: 96 return stream 97 else: 98 return render_stream(stream, method=method, template_name=template)
56 def render_template(self, template_name, **context): 57 t = self.jinja_env.get_template(template_name) 58 return Response(t.render(**context), mimetype='text/html')
79 async def render_template(template_name_or_list: Union[str, List[str]], **context: Any) -> str: 80 """Render the template with the context given. 81 82 Arguments: 83 template_name_or_list: Template name to render of a list of 84 possible template names. 85 context: The variables to pass to the template. 86 """ 87 await current_app.update_template_context(context) 88 template = current_app.jinja_env.get_or_select_template(template_name_or_list) 89 return await _render(template, context)
7 def render(request, template_name, dictionary=None, **kwargs): 8 dictionary = process_context(template_name, dictionary, kwargs.pop('context_instance', None)) 9 template_name = prefix_templates(template_name, dictionary) 10 return django_render(request, template_name, dictionary, **kwargs)
25 def render(self, template_name, context, request=None): 26 template_name = self.template_mappings.get(template_name, template_name) 27 template = self.get_template(template_name) 28 return template.render(context, request=request).strip()
57 def renderTemplate(request, templatePath, **kw): 58 template = getTemplate(templatePath) 59 return renderTemplateObj(request, template, **kw)
119 def render(self, template, ns): 120 ns.pop('self',None) 121 stream = self.loader.load(template).generate(Context(**ns)) 122 return stream.render(method='xhtml', doctype='xhtml')
26 def template(template_name, **kwargs): 27 # register this template name 28 rtemplate = _Template(template_name, **kwargs) 29 _templates.append(rtemplate) 30 31 def wrapper(func): 32 async def wrapped(*args): 33 namespace = await func(*args) 34 text = rtemplate.ctemplate.render(namespace) 35 return web.Response(body=text.encode('utf-8'), **rtemplate.kwargs) 36 37 return wrapped 38 39 return wrapper