High-performance Liquid template engine powered by Zig
Project description
Liquidz Python Binding
High-performance Liquid template engine for Python, powered by Zig.
Installation
pip install liquidz
Prerequisites: You need to build the Zig library first:
cd ../.. # Go to project root
zig build -Doptimize=ReleaseFast
Usage
from liquidz import render
# Simple variable substitution
result = render("Hello, {{ name }}!", {"name": "World"})
print(result) # "Hello, World!"
# With loops
result = render("{% for item in items %}{{ item }} {% endfor %}", {"items": ["a", "b", "c"]})
print(result) # "a b c "
# With conditionals
result = render("{% if show %}visible{% endif %}", {"show": True})
print(result) # "visible"
# With filters
result = render("{{ name | upcase }}", {"name": "hello"})
print(result) # "HELLO"
# Using JSON string directly
result = render("{{ x }}", '{"x": 42}')
print(result) # "42"
# Empty data (defaults to {})
result = render("Hello")
print(result) # "Hello"
API
render(template, data=None)
Renders a Liquid template with the given data.
Parameters:
template(str): The Liquid template stringdata(dict | str | None): The data to render with. Can be a dict or a JSON string. Defaults toNone(empty dict).
Returns:
str: The rendered template
Raises:
RenderError: If rendering failsLiquidzError: If the library cannot be loaded
render_string(template, data=None)
Alias for render().
Exceptions
LiquidzError: Base exception for all Liquidz errorsRenderError: Raised when template rendering fails
Running Tests
pip install pytest
pytest
License
MIT
Project details
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 Distributions
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 liquidz-0.2.3-py3-none-any.whl.
File metadata
- Download URL: liquidz-0.2.3-py3-none-any.whl
- Upload date:
- Size: 195.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bc5478ab154c061a3e0fd98676cd90105165dc8cecddf91d7c5077a80f03a26
|
|
| MD5 |
7ced63d640579ac65a497655d0f96528
|
|
| BLAKE2b-256 |
fd23013e003c2ce16ac5b4df748414f783f7a6a59d16247c11798b91d613fdbe
|
Provenance
The following attestation bundles were made for liquidz-0.2.3-py3-none-any.whl:
Publisher:
release.yml on pepicrft/liquidz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liquidz-0.2.3-py3-none-any.whl -
Subject digest:
5bc5478ab154c061a3e0fd98676cd90105165dc8cecddf91d7c5077a80f03a26 - Sigstore transparency entry: 787020963
- Sigstore integration time:
-
Permalink:
pepicrft/liquidz@8ad5d8d4437dcb79ec65ac55242906346dafdf65 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pepicrft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8ad5d8d4437dcb79ec65ac55242906346dafdf65 -
Trigger Event:
push
-
Statement type: