Skip to content
forked from pwwang/liquidpy

A port of liquid template engine for python

License

Notifications You must be signed in to change notification settings

oxalorg/liquidpy

 
 

Repository files navigation

liquidpy

A port of liquid template engine for python

Pypi Github PythonVers ReadTheDocs building Travis building Codacy Codacy coverage

Install

pip install liquidpy

Current status and plans

  • Note that this branch is not fully compatible with shopify's liquid. For compatible versions, please check branches lark and larkone.
  • This branch is current NOT safe agaist malicious input (#22), so we tried to re-implement the engine using lark-parser. However, both versions were very slow for lexer.
  • With branch lark, we tried to tokenize each tag and parse the content of the tags later using independent parsers, while with larkone, we tried to put all grammars together, and made it into a universal parser. However, both of them are slow, due to tokenization of whole tags (raw and comment) and literals (See grammar.lark in the code).
  • If you have a better grammar or idea for tokenization, you are very welcome to submit issues or PRs (writing naive lexer is just too much work).
  • We left some APIs to extend the lark ones with some functions from master. However, it won't happen before we find a faster lexer.
  • A temporary plan for the master branch is to do some security check to address #22.

Full Documentation

ReadTheDocs

Baisic usage

from liquid import Liquid
liq = Liquid('{{a}}')
ret = liq.render(a = 1)
# ret == '1'

# load template from a file
liq = Liquid('/path/to/template', liquid_from_file=True)

With environments:

liq = Liquid('{{a | os.path.basename}}', os=__import__('os'))
ret = liq.render(a="path/to/file.txt")
# ret == 'file.txt'

About

A port of liquid template engine for python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%