A port of liquid template engine for python
This is compatible with standard Liquid template engine. Variations, such as Shopify and Jekyll are not fully supported yet.
pip install -U liquidpy
from liquid import Liquid
liq = Liquid('{{a}}')
ret = liq.render(a=1)
# ret == '1'
# with environments pre-loaded
liq = Liquid('{{a}}', a=1)
ret = liq.render()
# ret == '1'
# With debug on:
liq = Liquid('{{a}}', liquid_config={'debug': True})
We also support a python mode template engine, which acts more pythonic and powerful.
from liquid import Liquid
# standard liquid doesn't support this
liq = Liquid('{{a + 1}}', {'mode': 'python'})
ret = liq.render(a=1)
# ret == '2'
Both modes can accept a path, a file-like object or a stream for the template:
Liquid('/path/to/template')
# or
with open('/path/to/template') as f:
Liquid(f)
- Liquid's documentation
- Liquidpy's documentation
v0.6.0+
is a remodeled version to make it compatible with standard liquid engine. If you are using a previous version, stick with it. 0.6.0+
is not fully compatible with previous versions.