python-liquid 2.2.1
pip install python-liquid
Released:
A Python engine for the Liquid template language.
Navigation
Verified details
These details have been verified by PyPIMaintainers
๐ Avatar for jg-rp from gravatar.comjg-rp
Unverified details
These details have not been verified by PyPIProject links
Meta
-
License Expression: MIT
SPDX License Expression - Author: James Prior
- Requires: Python >=3.9
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
Project description
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:
$pipenvinstall-upython-liquid
Or pip:
$pipinstallpython-liquid
Or from conda-forge:
$condainstall-cconda-forgepython-liquid
Links
- Documentation: https://jg-rp.github.io/liquid/
- Documentation for Python Liquid version 1.x: https://jg-rp.github.io/python-liquid-docs-archive/
- Change Log: https://github.com/jg-rp/liquid/blob/main/CHANGES.md
- PyPi: https://pypi.org/project/python-liquid/
- Source Code: https://github.com/jg-rp/liquid
- Issue Tracker: https://github.com/jg-rp/liquid/issues
Related Projects
- Python Liquid2: A new Python engine for Liquid with extra features.
- Ruby Liquid2: Liquid2 templates for Ruby.
- Micro Liquid: A stripped-down Liquid-like template engine for Python. You can think of it as a non-evaluating alternative to Python's f-strings or t-strings.
- LiquidScript: A JavaScript engine for Liquid with a similar high-level API to 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".
fromliquidimport 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.
fromliquidimport 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.
fromliquidimport CachingFileSystemLoader fromliquidimport 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.
Project details
Verified details
These details have been verified by PyPIMaintainers
๐ Avatar for jg-rp from gravatar.comjg-rp
Unverified details
These details have not been verified by PyPIProject links
Meta
-
License Expression: MIT
SPDX License Expression - Author: James Prior
- Requires: Python >=3.9
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_liquid-2.2.1.tar.gz.
File metadata
- Download URL: python_liquid-2.2.1.tar.gz
- Upload date:
- Size: 95.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a800c3aa47f7614893f3dc3381ec07587ef04d5e076a8e4b266a81cdbe512c8c
|
|
| MD5 |
592d9e146944813dd4cc9f1b5f446b60
|
|
| BLAKE2b-256 |
f60538a825b18c6a08d4b42b9b8a4ec0fb08babe2e815ab47d866af09b8bfd63
|
File details
Details for the file python_liquid-2.2.1-py3-none-any.whl.
File metadata
- Download URL: python_liquid-2.2.1-py3-none-any.whl
- Upload date:
- Size: 140.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35da55dc42c47ebc86086b18838d1921135f48940599b7537f9a55645974e49c
|
|
| MD5 |
b94ffae6a719dd04c6242c87d615aa4d
|
|
| BLAKE2b-256 |
a818ee9c53e015ad4b2be471107714ce4db562090fee7b1fd4cb1f299e2b0e78
|
