Downloads
Stars
Version
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:
Why another templating library?
Liquid was written to meet three templating library requirements: good performance, easy to extend, and simply to use.
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
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"
{% 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 %}
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.
Have a bug? Please create an issue here on GitHub!