This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/lib/utils/template.py
2018-11-16 10:08:15 +01:00

15 lines
453 B
Python

"""passbook lib template utilities"""
from django.template import Context, Template, loader
def render_from_string(template: str, ctx: Context) -> str:
"""Render template from string to string"""
template = Template(template)
return template.render(ctx)
def render_to_string(template_path: str, ctx: Context) -> str:
"""Render a template to string"""
template = loader.get_template(template_path)
return template.render(ctx)