定制 lucid/template 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lucid/template

Composer 安装命令:

composer require lucid/template

包简介

Templating library

关键字:

README 文档

README

Author Source Code Software License

Build Status Code Coverage HHVM

An extendable templating library for php.

Requirements

php >= 5.6

Installation

$ composer require lucid/template

Getting started

<?php

use Lucid\Template\Engine;
use Lucid\Template\Loader\FilesystemLoader;

$engine = new Engine(new Loader(['path/to/templates']));

$engine->render('partials/content.php', ['title' => 'Hello World!']);

Partials

Inserts

<html>
    <body>

    <div id="container">
        $view->insert('partials/footer.php');
        $view->insert('partials/content.php');
        $view->insert('partials/footer.php');
    </div>

    </body>
</html>

Extending existing templates

The templates

partials/content.php:

<?= $view->extend('master.php') ?>
<?= $view->section('content') ?>
    <p>Extended content</p>
<?= $view->endsection() ?>

master.php:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title><?= $title ?></title>
  </head>
  <body>
    <div id="main">
      <?= $view->section('content') ?>
        <p>The default content.</p>
      <?= $view->endsection() ?>
    </div>
  </body>
</html>

Sections

Tempalte Listeners

Adding template listeners can be usefull if you want to add data to a specific template. This data my be derieved from any resource you may want (e.g. DB, Container, etc).

<?php

$view->addListener('head.php', new RenderHeadListener($headerData));

Your listener may look something like this

<?php

use Lucid\Template\Listener\ListenerInterface;

class RenderHeadListener implements ListenerInterface
{
	private $data;

	public function __construct(array $headerData)
	{
		$this->data = $data;
	}

    public function onRender(TemplateDataInterface $data)
	{
		// add header data to `$data`
	}
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固