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.
2018-11-16 09:08:15 +00:00
|
|
|
"""passbook lib template utilities"""
|
|
|
|
from django.template import Context, Template, loader
|
|
|
|
|
|
|
|
|
2019-10-01 08:17:39 +00: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 08:17:39 +00: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)
|