codemade-xyz/php-liquid-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codemade-xyz/php-liquid-bundle

Composer 安装命令:

composer require codemade-xyz/php-liquid-bundle

包简介

Symfony LiquidBundle template engine for PHP

README 文档

README

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!

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固