Skip to content

lingfromSh/liquidpy

 
 

Repository files navigation

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.

About

A port of liquid template engine for python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.6%
  • Other 0.4%