Skip to main content

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 string
  • data (dict | str | None): The data to render with. Can be a dict or a JSON string. Defaults to None (empty dict).

Returns:

  • str: The rendered template

Raises:

  • RenderError: If rendering fails
  • LiquidzError: If the library cannot be loaded

render_string(template, data=None)

Alias for render().

Exceptions

  • LiquidzError: Base exception for all Liquidz errors
  • RenderError: Raised when template rendering fails

Running Tests

pip install pytest
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

liquidz-0.6.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.3 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

liquidz-0.6.0-py3-none-macosx_11_0_arm64.whl (197.0 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

liquidz-0.6.0-py3-none-macosx_10_9_x86_64.whl (197.0 kB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file liquidz-0.6.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for liquidz-0.6.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 280bb2787c1578d384a1fdc3a7e408495494768d890796ec817af4a2fcb81aeb
MD5 54b72f0f237d18bd036679a2b9907196
BLAKE2b-256 4685d6cc41066106f93fded41012709f0ff28b68ec458599ce11d106212a85e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for liquidz-0.6.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on pepicrft/liquidz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file liquidz-0.6.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for liquidz-0.6.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 397cf5e320348836a60f14de841411c9eeea4efc6b9d563de2894d6414a68f53
MD5 0bd78c3fe781ee1c572bfe8f33a1ce46
BLAKE2b-256 1acb566304641a3415c05ca5a02d8e267538b8e6eec408795ce3f20ea1048dba

See more details on using hashes here.

Provenance

The following attestation bundles were made for liquidz-0.6.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on pepicrft/liquidz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file liquidz-0.6.0-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for liquidz-0.6.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9356b2bbbe5a7b663ce4b31796f2184bcf7033d40b209033dfb8ec620d41cfc6
MD5 d42cbe85204fd3c39057f10371a2dd3b
BLAKE2b-256 3bf2fb3fe39b178171bc37807599d98b55b3bd13b900c139e253ec1cae248fd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for liquidz-0.6.0-py3-none-macosx_10_9_x86_64.whl:

Publisher: release.yml on pepicrft/liquidz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page