Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Liquid Bundle Laravel Package

codemade-xyz/php-liquid-bundle

View on GitHub
Deep Wiki
Context7

Symfony 5.1 Liquid Bundle - 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)

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 codemade-xyz/php-liquid-bundle

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 in Symfony

1. Connect bundle in file bundle.php or kernel.php

Example add in kernel.php

public function registerBundles()
{
    $bundles = array(
        ...
        new \CodeMade\LiquidBundle\LiquidBundle()
    );
    
    return $bundles;
}

2. Here is a simple example config

In config file add setting, if no values ​​are specified, then the default settings will be used.

liquid:
  cache: '%kernel.cache_dir%/liquid'
  default_path: '%kernel.project_dir%/templates'
  filter: App\Kernel\LiquidTemplateFilter
  include_suffix: 'tpl'
  include_prefix: ''
  tags:
    section: App\Kernel\LiquidTagSection
  paths:
    'App': '%kernel.project_dir%/templates/App'

3. In config file framework.yaml

Add setting in framework.yaml

framework:
  ...
  templating:
    engines: ['liquid']

4. Use the standard functions in the controller to process the template.

<?php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class Index extends AbstractController
{

    /**
     * @Route("/")
     */
    public function index()
    {
        return $this->render('@App/home', [
            'document' => [
                'title' => 'Home page'
            ]
        ]);

    }

}

Requirements

  • PHP 7.1+

Fork notes and contributors

This bundle create for Symfony and use
harrydeluxe library Liquid!

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
aimeos/prisma
besmartand-pro/php-quality-config
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views