Convenience methods

The fastest path to rendered output. Each method returns the output string directly.

  • Sync

  • Async

html = client.render_html("template-id")
tsx  = client.render_react("template-id")
mjml = client.render_mjml("template-id")
html = await client.render_html("template-id")
tsx  = await client.render_react("template-id")
mjml = await client.render_mjml("template-id")

All three accept an optional dynamic_data argument:

html = client.render_html("template-id", {
    "merge_tags": {"text": {"name": "Noruwa"}},
    "context":    {"plan": "pro"},
})

render() — full control

Use render() when you need the full result object or want to specify the target dynamically.

  • Sync

  • Async

result = client.render(
    template_id="550e8400-e29b-41d4-a716-446655440000",
    target="html",       # "html" | "react-email" | "mjml"
    dynamic_data={
        "merge_tags": {"text": {"name": "Noruwa"}},
        "context":    {"plan": "pro"},
    },
)

print(result.output)       # rendered string
print(result.target)       # "html"
print(result.template_id)  # "550e8400-..."
result = await client.render(
    template_id="550e8400-e29b-41d4-a716-446655440000",
    target="react-email",
    dynamic_data={
        "merge_tags": {"text": {"name": "Noruwa"}},
    },
)

render() parameters

Parameter Type Required Description

template_id

str (UUID)

The template to render.

target

RenderTarget

"html" (default), "react-email", or "mjml".

dynamic_data

DynamicData | None

Merge tags and context. See Dynamic Data.

RenderResult dataclass

render() returns a frozen RenderResult dataclass:

@dataclass(frozen=True)
class RenderResult:
    output:      str           # the rendered template string
    target:      RenderTarget  # "html" | "react-email" | "mjml"
    template_id: str           # the UUID that was rendered

Without dynamic data

If the template has no merge tags or visibility rules:

html = client.render_html("template-id")
# or
result = client.render(template_id="template-id")