承接 playsms/tpl 相关项目开发

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

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

playsms/tpl

Composer 安装命令:

composer require playsms/tpl

包简介

Dead simple PHP template engine

README 文档

README

Dead simple PHP template engine

Information Description
Author Anton Raharja
Contant araharja at pm dot me
Version 1.0.11
Release date 140422
Last update 231117

Install

Using composer by providing or editing composer.json.

Minimum composer.json:

{
	"require": {
		"playsms/tpl": "1.*"
	}
}

More information about composer can be found at its website https://getcomposer.org

This package can also be installed without composer. You can simply include the src/Playsms/Tpl.php.

Usage example

An example template file the_page.html:

<div>
	<p>This is the title: {{ title }}</p>
	<p>This is the content: {{ content }}</p>
	<p>And this is the data: {{ $data }}</p>
	<loop.lines>
	<p style='background-color: {{ lines.hexcode }}'>Color: {{ lines.color }}</p>
	</loop.lines>
</div>

Example PHP file show_page.php using the template file the_page.html:

<?php

require 'vendor/autoload.php';

$data = 'THE DATA HERE';

$loops = array(
	'lines' => array(
		array('color' => 'Red',   'hexcode' => '#FF0000'),
		array('color' => 'Green', 'hexcode' => '#00FF00'),
		array('color' => 'Blue',  'hexcode' => '#0000FF'),
	),
);

$tpl = new \Playsms\Tpl;

$tpl->setTemplate('./templates/test6.html');

$tpl->setVars(array(
	'title' => 'THE TITLE HERE',
	'content' => 'THE CONTENT HERE',
	))
	->setLoops($loops)
	->setInjects(array('data'));

$tpl->compile();

echo $tpl->getCompiled();

After compile() you can get compiled content using getCompiled():

<div>                                                                                                                                                        
    <p>This is the title: THE TITLE HERE</p>                                                                                                                 
    <p>This is the content: THE CONTENT HERE</p>                                                                                                             
    <p>And this is the data: THE DATA HERE</p>                                                                                                               
                                                                                                                                                             
    <p style='background-color: #FF0000'>Color: Red</p>                                                                                                      
                                                                                                                                                             
    <p style='background-color: #00FF00'>Color: Green</p>                                                                                                    
                                                                                                                                                             
    <p style='background-color: #0000FF'>Color: Blue</p>                                                                                                     
                                                                                                                                                             
</div>

For more examples please see examples folder.

Other documents can be found in docs folder.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固