Skip to main content

trmnl-liquid-py

A Python compatibility layer for usetrmnl/trmnl-liquid, targeting byte-for-byte compatible rendering for the supported TRMNL Liquid 0.8.2 surface.

[!NOTE] The first release target is trmnl-liquid-py 0.1.0, compatible with trmnl-liquid 0.8.2 for the supported non-I18n surface. Rails/ActionView and full I18n behavior are intentionally deferred.

Installation

Once 0.1.0 is published to PyPI:

python -m pip install trmnl-liquid-py

Python 3.11–3.14 is supported.

Quick start

from trmnl_liquid import Environment

env = Environment()
template = env.from_string("Hello {{ name }}!")
print(template.render(name="TRMNL"))

For one-shot rendering:

from trmnl_liquid import render

html = render("{{ value | number_with_delimiter }}", value=1234567)

Inline templates

TRMNL adds an inline {% template %} definition that can later be rendered with Liquid's {% render %} tag:

{% template card %}
<div>{{ title }}</div>
{% endtemplate %}

{% render 'card', title: 'Status' %}

trmnl-liquid-py reproduces TRMNL 0.8.2's raw-body and template-storage semantics, including its exact {% endtemplate %} terminator behavior.

TRMNL filters

The 0.1.0 compatibility surface includes:

  • append_random
  • days_ago
  • group_by
  • find_by
  • markdown_to_html
  • number_with_delimiter
  • number_to_currency
  • l_word fallback behavior
  • l_date fallback behavior
  • map_to_i
  • pluralize
  • json
  • parse_json
  • sample
  • where_exp
  • ordinalize
  • qr_code

Important TRMNL/Ruby syntax differences are preserved where required. For example, Ruby Liquid's lax filter syntax accepts a leading comma before the first filter argument:

{{ value | qr_code, 11 }}

Markdown

markdown_to_html reproduces the tested output of TRMNL 0.8.2's default Redcarpet 3.6.1 configuration using Mistune on Python.

{{ markdown | markdown_to_html }}

QR codes

qr_code renders the SVG shape expected from TRMNL's RQRCode-based implementation, including compatible QR mask selection/scoring behavior.

{{ 'https://example.com' | qr_code: 11 }}

Compatibility target

The baseline is exactly:

  • trmnl-liquid 0.8.2
  • Python 3.11, 3.12, 3.13, 3.14
  • non-I18n behavior
  • Rails/ActionView and full localized l_word / l_date behavior deferred
  • features added after upstream 0.8.2 excluded until a later compatibility target is adopted

Ruby trmnl-liquid 0.8.2 is the reference implementation. Differences in parsing, coercion, formatting, Markdown rendering, QR generation, template behavior, error handling, or rendered output are treated as compatibility issues when they affect the supported scope.

Compatibility evidence

Gate Result
Ruby 0.8.2 vs Python exact differential corpus 574/574
Known mismatches in the supported scope 0
Official TRMNL 0.8.2 RSpec examples mapped 73/73
Upstream examples covered by exact differential tests 46
Upstream examples covered by property/unit tests 16
Upstream examples covered in the initial non-I18n scope 62/73
Deferred Rails/I18n upstream examples 11
Python CI matrix 3.11, 3.12, 3.13, 3.14
Comparison exact rendered output

The Compatibility workflow runs the Ruby oracle first and fails on any mismatch. It then checks that this generated report still matches the checked-in corpus and upstream-spec manifest.

See COMPATIBILITY.md for the compatibility contract, upstream spec mapping, and Ruby oracle details.

Development

Install the project with development dependencies, then run the normal quality gates:

python -m pip install -e . pytest ruff mypy build twine \
  types-python-dateutil==2.9.0.20260807 \
  types-qrcode==8.2.0.20260518
ruff check .
mypy src/trmnl_liquid
pytest
python -m build
twine check dist/*

The Ruby/Python differential suite additionally requires Ruby and the bundle in compatibility/ruby:

bundle install --gemfile compatibility/ruby/Gemfile
python compatibility/compare.py
python -m compatibility.report --check

Release process

Releases are tag-driven. There is no manual publish workflow and no PyPI API token stored in GitHub.

  1. Update src/trmnl_liquid/__about__.py and CHANGELOG.md in a normal PR.
  2. Merge the PR to main and wait for both CI and Compatibility to pass on main.
  3. Create and push a tag whose name is exactly the package version, for example 0.1.0.
  4. The Release workflow verifies that the tag equals __version__ and points to a commit on main.
  5. The workflow builds and validates the wheel/sdist, publishes them to PyPI through Trusted Publishing, and only after a successful PyPI publish creates the matching GitHub Release with the distributions attached.

A tag such as v0.1.0 is intentionally invalid when __version__ == "0.1.0".

License

MIT. The repository license includes attribution for portions derived from usetrmnl/trmnl-liquid.

Download files

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

Source Distribution

trmnl_liquid_py-0.1.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

trmnl_liquid_py-0.1.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file trmnl_liquid_py-0.1.0.tar.gz.

File metadata

  • Download URL: trmnl_liquid_py-0.1.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trmnl_liquid_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec45bc45c9bd34bd8b73c2d38d9f86db9bb404d67843e6516e416181bce16f1c
MD5 c447b44ee072fc47c4ba3cf12be45d7a
BLAKE2b-256 bf9b969c19d5ad0875217dc38f1971e872d32ea9ff174e2700b1e0225a5a640b

See more details on using hashes here.

Provenance

The following attestation bundles were made for trmnl_liquid_py-0.1.0.tar.gz:

Publisher: release.yml on Misiu/trmnl-liquid-py

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

File details

Details for the file trmnl_liquid_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trmnl_liquid_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trmnl_liquid_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14bdc74337831b8c98fe4f9ecdec8362c35d6d04758901a4a45455c44fa33ddc
MD5 73e2c534c3ef1a6729f1d28291adb6cf
BLAKE2b-256 c484708d56b84eec04175794fda760ce9382be212946326dfcd41b5e6a5252b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for trmnl_liquid_py-0.1.0-py3-none-any.whl:

Publisher: release.yml on Misiu/trmnl-liquid-py

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page