New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

simexis/laravel-liquid

Liquid template engine for Laravel
1,512 18
Install
composer require simexis/laravel-liquid
Latest Version:0.10.10
PHP:>= 5.6
Laravel:5 – 9
License:MIT
Last Updated:Oct 18, 2022
Links: GitHub  ·  Packagist
Maintainer: jooorooo

Liquid template engine for Laravel

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.
  • 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.

Installing

You can install this lib via composer:

composer require simexis/laravel-liquid

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider

Laravel 5.5+:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Liquid\LiquidServiceProvider::class,

If you want to use the facade to compiler:

'Liquid' => Liquid\Facade::class,
php artisan vendor:publish --provider="Liquid\LiquidServiceProvider"

Example template

{% if products %}
	<ul id="products">
	{% for product in products %}
	  <li>
		<h2>{{ product.name }}</h2>
		Only {{ product.price | price }}

		{{ product.description | prettyprint | paragraph }}

		{{ 'it rocks!' | paragraph }}

	  </li>
	{% endfor %}
	</ul>
{% endif %}

How to use Liquid

class HomeController extends Comtroller {
    
    public function index() 
    {
        $products = Products::all();
        
        return view('home', [
            'products' => $products 
        ]);  
    }
    
}

To find more examples at the original Ruby implementation repository's wiki page.

Requirements

Issues

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

https://github.com/jooorooo/laravel-liquid/issues

Related Packages

corb/template-manager

Template manager for laravel

74 0
abitofmaya/blade-renderer

Standalone Blade Template Renderer

7 0
keepsuit/laravel-liquid

Liquid template engine for Laravel

68,336 9
tomatophp/filament-wallet

Account Balance / Wallets Manager For FilamentPHP and Filament Account Builder

33,498 38
tomatophp/filament-subscriptions

Manage subscriptions and feature access with customizable plans in FilamentPHP

10,139 64

Version History

Version Released PHP Laravel License
0.10.10 >= 5.6 >=5.3 MIT
0.10.09 >= 5.6 >=5.3 MIT
0.10.08 >= 5.6 >=5.3 MIT
0.10.07 >= 5.6 >=5.3 MIT
0.10.06 >= 5.6 >=5.3 MIT