All Projects → jg-rp → liquid

jg-rp / liquid

Licence: MIT license
A Python engine for the Liquid template language.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to liquid

dry
Dry is a new template engine and language, and is a superset of Shopify's Liquid, with first-class support for advanced inheritance features, and more. From the creators of Enquirer, Assemble, Remarkable, and Micromatch.
Stars: ✭ 66 (+65%)
Mutual labels:  template-engine, templates, liquid, liquid-templating-engine
liquidpy
A port of liquid template engine for python
Stars: ✭ 49 (+22.5%)
Mutual labels:  template-engine, liquid, liquid-templating-engine
korte
Kotlin cORoutines Template Engine for Multiplatform Kotlin
Stars: ✭ 69 (+72.5%)
Mutual labels:  template-engine, liquid
lua-resty-aries
openresty and lua multi-function template
Stars: ✭ 47 (+17.5%)
Mutual labels:  template-engine, templates
Email Templates
📫 Create, preview, and send custom email templates for Node.js. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more!
Stars: ✭ 3,291 (+8127.5%)
Mutual labels:  template-engine, templates
LiquidKit
Liquid template language parser engine in Swift.
Stars: ✭ 19 (-52.5%)
Mutual labels:  template-engine, liquid-templating-engine
nunjucks-loader
Webpack loader for Nunjucks templates
Stars: ✭ 20 (-50%)
Mutual labels:  template-engine, templates
Cookie
A Template-based File Generator. Like cookiecutter but works with file templates instead of project templates.
Stars: ✭ 261 (+552.5%)
Mutual labels:  template-engine, templates
layouts
Wraps templates with layouts. Layouts can use other layouts and be nested to any depth. This can be used 100% standalone to wrap any kind of file with banners, headers or footer content. Use for markdown, HTML, handlebars views, lo-dash templates, etc. Layouts can also be vinyl files.
Stars: ✭ 28 (-30%)
Mutual labels:  templates, liquid
Jinja
A very fast and expressive template engine.
Stars: ✭ 8,170 (+20325%)
Mutual labels:  template-engine, templates
Liquidjs
A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
Stars: ✭ 638 (+1495%)
Mutual labels:  template-engine, liquid
Jade
Jade.go - pug template engine for Go (golang)
Stars: ✭ 251 (+527.5%)
Mutual labels:  template-engine, templates
liquid.cr
Kind of liquid template engine for Crystal [WIP]
Stars: ✭ 64 (+60%)
Mutual labels:  template-engine, liquid
Liquid.net
.Net Port of the Liquid template language
Stars: ✭ 47 (+17.5%)
Mutual labels:  templates, liquid
Handlebars.java
Logic-less and semantic Mustache templates with Java
Stars: ✭ 1,204 (+2910%)
Mutual labels:  template-engine, templates
Jinja2cpp
Jinja2 C++ (and for C++) almost full-conformance template engine implementation
Stars: ✭ 257 (+542.5%)
Mutual labels:  template-engine, templates
gulp-shopify-theme
Shopify theme synchronisation during development
Stars: ✭ 26 (-35%)
Mutual labels:  liquid, liquid-templating-engine
react-liquid
Liquid templating language component for React
Stars: ✭ 50 (+25%)
Mutual labels:  liquid, liquid-templating-engine
Mikado
Mikado is the webs fastest template library for building user interfaces.
Stars: ✭ 323 (+707.5%)
Mutual labels:  template-engine, templates
Solid
Liquid template engine in Elixir
Stars: ✭ 68 (+70%)
Mutual labels:  template-engine, liquid

Python Liquid

A Python engine for Liquid, the safe customer-facing template language for flexible web apps.

License
PyPi - Version conda-forge
Python versions PyPy versions
Tests Coverage


Table of Contents

Install

Install Python Liquid using Pipenv:

$ pipenv install -u python-liquid

Or pip:

$ pip install python-liquid

Or from conda-forge:

$ conda install -c conda-forge python-liquid

Links

Example

from liquid import Template

template = Template("Hello, {{ you }}!")
print(template.render(you="World"))  # "Hello, World!"
print(template.render(you="Liquid"))  # "Hello, Liquid!"

Related Projects

  • liquid-babel Internationalization and localization for Liquid templates.
  • LiquidScript: A JavaScript and TypeScript engine for Liquid with a similar high-level API to Python Liquid.
  • django-liquid: A Django template backend for Liquid. Render Liquid templates in your Django apps.
  • Flask-Liquid: A Flask extension for Liquid. Render Liquid templates in your Flask applications.
  • golden-liquid: A test suite for Liquid. See how various Liquid template engines compare to the reference implementation.

Compatibility

We strive to be 100% compatible with the reference implementation of Liquid, written in Ruby. That is, given an equivalent render context, a template rendered with Python Liquid should produce the same output as when rendered with Ruby Liquid.

See the known issues page for details of known incompatibilities between Python Liquid and Ruby Liquid, and please help by raising an issue if you notice an incompatibility.

Benchmark

You can run the benchmark using hatch run benchmark (or python -O scripts/performance.py if you don't have make) from the root of the source tree. On my ropey desktop computer with a Ryzen 5 1500X and Python 3.11.0, we get the following results.

Best of 5 rounds with 100 iterations per round and 60 ops per iteration (6000 ops per round).

lex template (not expressions): 1.2s (5020.85 ops/s, 83.68 i/s)
                    lex and parse: 5.0s (1197.32 ops/s, 19.96 i/s)
                        render: 1.4s (4152.92 ops/s, 69.22 i/s)
            lex, parse and render: 6.5s (922.08 ops/s, 15.37 i/s)

And PyPy3.7 gives us a decent increase in performance.

Best of 5 rounds with 100 iterations per round and 60 ops per iteration (6000 ops per round).

lex template (not expressions): 0.58s (10308.67 ops/s, 171.81 i/s)
                    lex and parse: 3.6s (1661.20 ops/s, 27.69 i/s)
                        render: 0.95s (6341.14 ops/s, 105.69 i/s)
            lex, parse and render: 4.6s (1298.18 ops/s, 21.64 i/s)

On the same machine, running rake benchmark:run from the root of the reference implementation source tree gives us these results.

/usr/bin/ruby ./performance/benchmark.rb lax

Running benchmark for 10 seconds (with 5 seconds warmup).

Warming up --------------------------------------
                parse:     3.000  i/100ms
            render:     8.000  i/100ms
    parse & render:     2.000  i/100ms
Calculating -------------------------------------
                parse:     39.072  (± 0.0%) i/s -    393.000  in  10.058789s
            render:     86.995  (± 1.1%) i/s -    872.000  in  10.024951s
    parse & render:     26.139  (± 0.0%) i/s -    262.000  in  10.023365s

I've tried to match the benchmark workload to that of the reference implementation, so that we might compare results directly. The workload is meant to be representative of Shopify's use case, although I wouldn't be surprised if their usage has changed subtly since the benchmark fixture was designed.

Contributing

Please see Contributing to Python Liquid.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].