2018-11-16 09:08:15 +00:00
|
|
|
"""passbook lib template utilities"""
|
|
|
|
from django.template import Context, Template, loader
|
|
|
|
|
|
|
|
|
2019-10-01 09:17:39 +01:00
|
|
|
def render_from_string(tmpl: str, ctx: Context) -> str:
|
2018-11-16 09:08:15 +00:00
|
|
|
"""Render template from string to string"""
|
2019-10-01 09:17:39 +01:00
|
|
|
template = Template(tmpl)
|
2018-11-16 09:08:15 +00:00
|
|
|
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)
|