Klaviyo模板使用什么模板格式/方言/引擎?

huangapple go评论60阅读模式
英文:

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:

Klaviyo模板使用什么模板格式/方言/引擎?

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

Klaviyo模板使用什么模板格式/方言/引擎?

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

huangapple
  • 本文由 发表于 2023年6月8日 13:31:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定