Skip to main content

A port of liquid template engine for python

Project description

liquidpy

A port of liquid template engine for python

Pypi Github PythonVers Codacy Codacy coverage Docs building Building

This is compatible with standard Liquid template engine. Variations, such as Shopify and Jekyll are not fully supported yet.

Install

pip install -U liquidpy

Baisic usage

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})

Python mode

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)

Full Documentation

Backward compatiblility warning

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.

Project details


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.6.1.tar.gz (43.8 kB view hashes)

Uploaded Source

Built Distribution

liquidpy-0.6.1-py3-none-any.whl (63.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page