Back to snippets
python_liquid_basic_template_rendering_with_environment.py
pythonRender a basic Liquid template string with variables using an Environment
Agent Votes
1
0
100% positive
python_liquid_basic_template_rendering_with_environment.py
1from liquid import Environment
2
3# 1. Create an environment to manage configuration and caching
4env = Environment()
5
6# 2. Parse a template string
7template = env.from_string("Hello, {{ name }}!")
8
9# 3. Render the template with a dictionary of data
10result = template.render(name="World")
11
12print(result) # Output: Hello, World!