Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/liquidpyPublic template

A port of liquid template engine for python

License

NotificationsYou must be signed in to change notification settings

pwwang/liquidpy

Repository files navigation

A port ofliquid template engine for python, on the shoulder ofjinja2

PypiGithubPythonVersDocs buildingTravis buildingCodacyCodacy coverage

Install

pip install -U liquidpy

Playground

Powered bypyscript:

https://pwwang.github.io/liquidpy/playground

Baisic usage

Loading a template

fromliquidimportLiquidliq=Liquid('{{a}}',from_file=False)ret=liq.render(a=1)# ret == '1'# load template from a fileliq=Liquid('/path/to/template.html')

Using jinja's environment

fromjinja2importEnvironment,FileSystemLoaderenv=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

fromliquidimportdefaults,Liquiddefaults.FROM_FILE=Falsedefaults.MODE='wild'# no need to pass from_file and mode anymoreliq=Liquid('{% from_ os import path %}{{path.basename("a/b.txt")}}')liq.render()# 'b.txt'

Documentation


[8]ページ先頭

©2009-2025 Movatter.jp