A PHP port of Ruby's Liquid Templates
Latest commit 38a8998 Dec 12, 2016 @harrydeluxe committed on GitHub Merge pull request #30 from kodekrash/master
refactor math filters to permit float variables (as ruby lib does)


Liquid template engine for PHP

Liquid is a PHP port of the Liquid template engine for Ruby, which was written by Tobias Lutke. Although there are many other templating engines for PHP, including Smarty (from which Liquid was partially inspired), Liquid had some advantages that made porting worthwhile:

  • Readable and human friendly syntax, that is usable in any type of document, not just html, without need for escaping.
  • Quick and easy to use and maintain.
  • 100% secure, no possibility of embedding PHP code.
  • Clean OO design, rather than the mix of OO and procedural found in other templating engines.
  • Seperate compiling and rendering stages for improved performance.
  • Easy to extend with your own tags and filters.
  • 100% Markup compatibility with a Ruby templating engine, making templates usable for either.
  • Unit tested: Liquid is fully unit-tested. The library is stable and ready to be used in large projects.

Why Liquid?

Why another templating library?

Liquid was written to meet three templating library requirements: good performance, easy to extend, and simply to use.


Example snippet:

{% if products %}
	<ul id="products">
	{% for product in products %}
		<h2>{{ product.name }}</h2>
		Only {{ product.price | price }}
		{{ product.description | prettyprint | paragraph }}
		{{ 'it rocks!' | paragraph }}
	{% endfor %}
{% endif %}

Howto use Liquid

Code to render:



  • PHP 5.1+


Have a bug? Please create an issue here on GitHub!


Fork Notes

This fork is based on php-liquid by Mateo Murphy. The original library is still hosted at: (http://code.google.com/p/php-liquid/)