Skip to main content

Python Liquid

Python Liquid is a Python engine for Liquid, the safe, customer-facing template language.
We follow Shopify/Liquid closely and test against the Golden Liquid test suite.

PyPi - Version conda-forge Python versions
Tests Coverage
PyPI - Downloads
License


Table of Contents

Install

Install Python Liquid using Pipenv:

$ pipenv install -u python-liquid

Or pip:

$ pip install python-liquid

Or from conda-forge:

$ conda install -c conda-forge python-liquid

Quick Start

render()

This example renders a template from a string of text with the package-level render() function. The template has just one placeholder variable you, which we've given the value "World".

from liquid import render

print(render("Hello, {{ you }}!", you="World"))
# Hello, World!

parse()

Often you'll want to render the same template several times with different variables. We can parse source text without immediately rendering it using the parse() function. parse() returns a BoundTemplate instance with a render() method.

from liquid import parse

template = parse("Hello, {{ you }}!")
print(template.render(you="World"))  # Hello, World!
print(template.render(you="Liquid"))  # Hello, Liquid!

Configure

Both parse() and render() are convenience functions that use the default Liquid environment. For all but the simplest cases, you'll want to configure an instance of Environment, then load and render templates from that.

from liquid import CachingFileSystemLoader
from liquid import Environment

env = Environment(
    autoescape=True,
    loader=CachingFileSystemLoader("./templates"),
)

Then, using env.parse() or env.get_template(), we can create a BoundTemplate from a string or read from the file system, respectively.

# ... continued from above
template = env.parse("Hello, {{ you }}!")
print(template.render(you="World"))  # Hello, World!

# Try to load "./templates/index.html"
another_template = env.get_template("index.html")
data = {"some": {"thing": [1, 2, 3]}}
result = another_template.render(**data)

Unless you happen to have a relative folder called templates with a file called index.html within it, we would expect a TemplateNotFoundError to be raised when running the example above.

Contributing

Please see Contributing to Python Liquid.

Metadata

Release files for python-liquid 2.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-liquid 2.3.2
File Size Uploaded
python_liquid-2.3.2.tar.gz 95.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-liquid 2.3.2
File Interpreter ABI Platform
python_liquid-2.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 237.0 kB

Release files / python_liquid-2.3.2.tar.gz

Download URL python_liquid-2.3.2.tar.gz
Size 95.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4bf0462275d1293ca8983b6d2448752ff1057c3ba3ca4858f8bbb6544e4f15ad
BLAKE2b-256 checksum
How to use checksums
223363c8e95c908a581d0d9c2d3dad2c629660780844a67e14b659b116a8c361
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / python_liquid-2.3.2-py3-none-any.whl

Download URL python_liquid-2.3.2-py3-none-any.whl
Size 141.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85b13b6933abed63d40f3d71c18384df886fc3be2d9c24d7d7264586e2b9c3f1
BLAKE2b-256 checksum
How to use checksums
e61240d61bec511b39b610c631f78d42e6f21138621ca59448c87d05ba97cb29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

2.3.4

2 release files

2.3.3

2 release files

This release

2.3.2 This release

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.12.2

2 release files

1.12.1

2 release files

1.10.2

2 release files

1.9.4

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.7

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page