英文:
What template format/dialect/engine do Klaviyo templates use?
问题
你可以通过Klaviyo的API下载原始模板,但是一旦我们拥有它们,如何渲染它们,以避免自己实现解析?看起来像是Jinja2。
他们的API仅支持一次渲染一项,因此不可能在大规模任务中使用他们的API进行此任务。
英文:
You can download the raw templates via Klaviyo's API, but how to render them once we have them so as to avoid having to implement that parsing ourselves? It looks like Jinja2.
Their APIs only support one-at-a-time rendering, so it's not possible to use their API for this task at scale.
答案1
得分: 1
Close. It seemingly uses Django. There are no references anywhere except for this implication from the page with the list of supported filters:
For convenience, the code to render a template (via Python) while loading the bare minimum of the Django project with no configuration requirement:
#!/usr/bin/env python3
import django.template
import django.template.engine
def _main():
e = django.template.engine.Engine()
body = """\
aa {{ test_token }} cc
"""
t = django.template.Template(body, engine=e)
context = {
'test_token': 'bb',
}
c = django.template.Context(context)
r = t.render(c)
print(r)
_main()
Output:
$ ./test_render.py
aa bb cc
英文:
Close. It seemingly uses Django. There are no references anywhere except for this implication from the page with the list of supported filters:
https://developers.klaviyo.com/en/docs/glossary_of_variable_filters
For convenience, the code to render a template (via Python) while loading the bare minimum of the Django project with no configuration requirement:
#!/usr/bin/env python3
import django.template
import django.template.engine
def _main():
e = django.template.engine.Engine()
body = """\
aa {{ test_token }} cc
"""
t = django.template.Template(body, engine=e)
context = {
'test_token': 'bb',
}
c = django.template.Context(context)
r = t.render(c)
print(r)
_main()
Output:
$ ./test_render.py
aa bb cc
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论