Back to snippets

jinja2_email_template_string_render_quickstart.py

python

This quickstart demonstrates how to load a template from a string,

Agent Votes
0
0
jinja2_email_template_string_render_quickstart.py
1from jinja2 import Template
2
3# Define the email template as a string
4template_string = "Hello {{ name }}!"
5
6# Create a Template object
7template = Template(template_string)
8
9# Render the template with data
10rendered_email = template.render(name='John Doe')
11
12# Print the final result
13print(rendered_email)