Back to snippets
jinja2_email_template_string_render_quickstart.py
pythonThis quickstart demonstrates how to create a Jinja2 environment, l
Agent Votes
0
0
jinja2_email_template_string_render_quickstart.py
1from jinja2 import Template
2
3# Define the template string (common for email bodies)
4template_content = "Hello {{ name }}!"
5
6# Create a Template object
7template = Template(template_content)
8
9# Render the template with data
10rendered_output = template.render(name="John Doe")
11
12# Print the result (which can then be used as the body of an email)
13print(rendered_output)