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.10-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.10-py3-none-macosx_11_0_arm64.whl (196.9 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

liquidz-0.2.10-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.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for liquidz-0.2.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d98850208689b1c26e89226926bc93d31052be3b8ab305925c1ae1fce914a421
MD5 41517425c14b7be3f8a226bf6a55bb9e
BLAKE2b-256 e45b374365ca4963c493de1fbbe288b13df80b8a50556a4d6b206df0558cc79d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for liquidz-0.2.10-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c0cc173bf64610d7e07731dad5735a91de08676da9413e8b9ba33bef3de55ab9
MD5 153100bf9852a0e845c294839320cc5f
BLAKE2b-256 21007542ed56add2a3b03cd112fca1185b7601319950f1203cfe5d32bcdd3e82

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for liquidz-0.2.10-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 95f2e5bb6d0c40b7c11ca60859d1f6de6cad14b05d04b3af086ad4d6f9f1b674
MD5 e781e5ee2802677a46c9e74d9771b6a6
BLAKE2b-256 bfeb511079b14661c819749357a461f96bf161f3d22c9af11200c4a4ad5fe1f3

See more details on using hashes here.

Provenance

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