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 Distribution

liquidz-0.2.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

liquidz-0.2.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file liquidz-0.2.0.tar.gz.

File metadata

  • Download URL: liquidz-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for liquidz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a1318e53d75164c721b423cd0683a4b6444ce482fe25286dbbe1606b7de62df3
MD5 fc1a05820ed3618deb27ee5424470ab4
BLAKE2b-256 b298b3e5d1cb36c3b31c9c0a9fd058bcdf8aef1fde2de3cf5288d5de4787bff4

See more details on using hashes here.

File details

Details for the file liquidz-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: liquidz-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for liquidz-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c63410da21f57729f46efc06ac0da2111d54a56ecfe8f5ed3036168d5cbadf21
MD5 332c659d954b1bf551d5c0c61127c9a9
BLAKE2b-256 38144bf5a43411378372dc698a8d9e79c45b1f153db9762ac666e40f202ae6ba

See more details on using hashes here.

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