A port of liquid template engine for python
Project description
liquidpy
A port of liquid template engine for python, on the shoulders of jinja2
Install
pip install -U liquidpy
Playground
Powered by pyscript:
https://pwwang.github.io/liquidpy/playground
Baisic usage
Loading a template
from liquid import Liquid
liq = Liquid('{{a}}', from_file=False)
ret = liq.render(a = 1)
# ret == '1'
# load template from a file
liq = Liquid('/path/to/template.html')
Using jinja's environment
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('./'), ...)
liq = Liquid.from_env("/path/to/template.html", env)
Switching to a different mode
liq = Liquid(
"""
{% python %}
from os import path
filename = path.join("a", "b")
{% endpython %}
{{filename}}
""",
mode="wild" # supported: standard(default), jekyll, shopify, wild
)
liq.render()
# 'a/b'
Changing default options
from liquid import defaults, Liquid
defaults.FROM_FILE = False
defaults.MODE = 'wild'
# no need to pass from_file and mode anymore
liq = Liquid('{% from_ os import path %}{{path.basename("a/b.txt")}}')
liq.render()
# 'b.txt'
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
liquidpy-0.9.0.tar.gz
(145.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
liquidpy-0.9.0-py3-none-any.whl
(32.9 kB
view details)
File details
Details for the file liquidpy-0.9.0.tar.gz.
File metadata
- Download URL: liquidpy-0.9.0.tar.gz
- Upload date:
- Size: 145.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fbffc4db5f31f815aecdfdc07c89761404a3fcdf5a03fd8563093bd63b6fd6a
|
|
| MD5 |
a2cba1ed6b896bda3225b739c5e76cc3
|
|
| BLAKE2b-256 |
d7474e4112d02f5af65d653998a9cbe166bb9806ea104ee56a5f57f067ebd353
|
File details
Details for the file liquidpy-0.9.0-py3-none-any.whl.
File metadata
- Download URL: liquidpy-0.9.0-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df590d9cf89599cf3ee1b017f77e98e1586022685f7d55c9fb2820095e134aa8
|
|
| MD5 |
0080479c4d5f32f78dfe2cc544cdd45a
|
|
| BLAKE2b-256 |
ad289f3700cb784c0f0475de7074ed489702d5c6fb63a3df56b4cb4333b055fc
|