承接 bixev/light-html-template 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bixev/light-html-template

最新稳定版本:2.0.12

Composer 安装命令:

composer require bixev/light-html-template

包简介

Bixev light HTML template system

README 文档

README

A simple html templating system with HTML-only templates, and only a few php commands.

It is scripting language agnostic and display language agnostic. You will have to know only 3 structure :

  • block : used to display none, one or many times a piece of code
  • var : used to display a value (optionnaly filtered)
  • import : used to import template from another file

Installation

It's recommended that you use Composer to install this lib.

composer require bixev/light-html-template "~1.0"

This will install this library and all required dependencies.

so each of your php scripts need to require composer autoload file

<?php require 'vendor/autoload.php';

Usage

HTML template

Your .html templates (or string) can only contain HTML and <bloc> / {var} to work.

Your php views will deal with conditions, loops and more

HTML content (into a .html template file, or into a string var from php) :

Before first bloc {{var1 | unknownFunction}} {{ unknownVar }}{{unknownVar | unknownFunction}} {{bloc:myFirstBloc}} first bloc start {{var1}} {{bloc:mySecondBloc}} content of second bloc with {{var}} {{bloc:my5thBloc}} content of 5th bloc with {{ var }} {{endbloc:my5thBloc}} {{endbloc:mySecondBloc}} first bloc middle {{var3 }} {{ bloc:myThirdBloc }} content of third bloc with {{var}} {{endbloc:myThirdBloc}} {{bloc:my4thBloc}} content of 4th bloc with {{var}} {{ endbloc:my4thBloc }} first bloc end {{ var3}} {{endbloc:myFirstBloc}} After first bloc {{var1}}

php content (your php view) :

<?php $tpl = \Bixev\LightHtmlTemplate\Factory::newTemplateFromString($template); $tpl->pB( [ 'var1' => 'testVal1', 'myFirstBloc' => [ 'var1' => 'testFirst1', 'var2' => 'testFirst2', 'var3' => 'testFirst3', 'mySecondBloc' => [ 'var' => 'testSecond', 'my5thBloc' => [ ['var' => 'test4th',], ['var' => 'test5th',], ], ], 'myThirdBloc' => [ ['var' => 'testThird1',], ['var' => 'testThird2',], ], ], ] ); $result = $tpl->render(); echo $result;

This will result in

Before first bloc testVal1 first bloc start testFirst1 content of second bloc with testSecond content of 5th bloc with test4th content of 5th bloc with test5th first bloc middle testFirst3 content of third bloc with testThird1 content of third bloc with testThird2 first bloc end testFirst3 After first bloc testVal1 

Test

vendor/bin/phpunit --bootstrap vendor/autoload.php ./test/BixevTest/LightHtmlTemplateTest/TplTest.php

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固