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.2.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (682.0 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

liquidz-0.2.8-py3-none-macosx_11_0_arm64.whl (196.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

liquidz-0.2.8-py3-none-macosx_10_9_x86_64.whl (196.8 kB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for liquidz-0.2.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8433f326a4982115f16a353fc8aaeef47ba30634fcb8ab30e223b519be97c4dd
MD5 f2e461283a3ad3a4e8a103fe0e86826c
BLAKE2b-256 dd9e29f0e07bdd887ce334685f67317cd4abe92bf1206f2ff07230c351e2ad6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for liquidz-0.2.8-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.2.8-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for liquidz-0.2.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9a121c6b0360ff6fa35960403867875390e5c3425f60e2b894a656324cfba5a
MD5 1f4c27f55ec01e5a837cab152e799c58
BLAKE2b-256 bb23063eff1acfcbb94a6669a691c4264acc2905a4b022c9749d0eeb9ed28afb

See more details on using hashes here.

Provenance

The following attestation bundles were made for liquidz-0.2.8-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.2.8-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for liquidz-0.2.8-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 eb012d251a52d1a164bba096ba0b70851e8abcbc743953a7d5891087e83e6f64
MD5 b5ad9e06283f3187f05d960d136bca7c
BLAKE2b-256 0ff9698001791ea142178fa43707d84346cdd645b4a2d0b30746d23f5618fc04

See more details on using hashes here.

Provenance

The following attestation bundles were made for liquidz-0.2.8-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