A port of liquid template engine for python
Project description
liquidpy
A port of liquid template engine for python, on the shoulder 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.8.2.tar.gz
(26.8 kB
view details)
Built Distribution
liquidpy-0.8.2-py3-none-any.whl
(32.5 kB
view details)
File details
Details for the file liquidpy-0.8.2.tar.gz
.
File metadata
- Download URL: liquidpy-0.8.2.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff7c1752bed93f4e2e90b35919b081e50ad290b82acbd4402c6fa37b2762a497 |
|
MD5 | 7bc969dda78ce7a0c20ae81a2eb4f621 |
|
BLAKE2b-256 | bafca9b06b2df510555a73c6fc69d471ea0023be1725a30730d57b2157864dd8 |
File details
Details for the file liquidpy-0.8.2-py3-none-any.whl
.
File metadata
- Download URL: liquidpy-0.8.2-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 641e090b63c2fd2c01b3046f9ae2d0dbfb2f388031d719e956c5d0cb2a5d2600 |
|
MD5 | de4cb63a4c60adca00beebd6bd4e45d3 |
|
BLAKE2b-256 | 6849df5f810ecde8b1632ad2b08306935c16e821436a76e61f0f09b317190829 |