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.8.6.tar.gz
(26.5 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.8.6-py3-none-any.whl
(32.8 kB
view details)
File details
Details for the file liquidpy-0.8.6.tar.gz.
File metadata
- Download URL: liquidpy-0.8.6.tar.gz
- Upload date:
- Size: 26.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66628cfc670f74f0fb545487b2b9e22322f62edabb2c70b20227bde48b9a818a
|
|
| MD5 |
35014450bfa1e02fecdbed6d6d97a221
|
|
| BLAKE2b-256 |
5aa2d86dfccccd5c8caabb7cc5ddd26c8fcf1657a3a3811b8860ea7d2c5a24a1
|
File details
Details for the file liquidpy-0.8.6-py3-none-any.whl.
File metadata
- Download URL: liquidpy-0.8.6-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
202caa21258221261ec6bc723065388ebe4803f41a49c59b4c4cbb4a32afa638
|
|
| MD5 |
be5760f38577ad6686a8adc6a0103224
|
|
| BLAKE2b-256 |
5b17f79ec86c7dcd96842000d48e47b793ec2d699e5ed523a5a5cc7e5f6d94ae
|