TPTtiny php template
关于TPT
TPT是php实现的用于模板解析小工具,全部实现仅仅60行代码。
配置
DIR_COMPILED和DIR_TEMPLATE,分别表示模版编译目录和模版文件目录:
define('DIR_COMPILED','/compiled_diy'); define('DIR_TEMPLATE','/template_diy');
默默使用compiled和template作为其默认的参数值。
使用方法:
php文件示例:
$title = 'welcome'; $users = array('alen', 'blen', 'calon'); include template('main');
header.html模版文件示例:
<html> <head> <meta http-equiv=content-type content="text/html; charset=UTF-8"> <title>{$title}</title> </head> <body>
main.html模版文件示例:
<!--{include header}--> <!--{loop $users $index $one}--> <li>${$index+1}-{$one}</li> <!--{/loop}--> <!--{include footer}-->
{}作为模版引擎的开始和结束标记,如果{}内部使用php运算符、函数调用等复杂语句,则需在{前加$,正确输出:
1-alen 2-blen 3-calon
footer.html模版文件示例:
</body> </html>
否则,标记里面的内容不会被解析,输出如下:
{$index+1}-alen {$index+1}-blen {$index+1}-calon
模版中可以使用简单的php控制结构,下面的示例中包含了循环结构的使用,另外,还支持if,if/else,if/elseif/else等条件判断,本模版本着“大道至简”的设计思想,简单实用就已经足够了,所以,也仅仅支持这两种控制结构。
<!--{loop $users $index $one}--> <!--{if $index==0}--> <li>${md5($one)}-{$one}</li> <!--{elseif $index==1}--> <li>${md5($one)}-{$one}</li> <!--{else}--> <li>${md5($one)}-{$one}</li> <!--{/if}--> <!--{/loop}-->
输出:
f3f7eb1421dcfed9a2614712ec608f1b-alen 37670a9c2cc598bcc271612af0617c3c-blen 82a8ea39dd2700b9c6dd207d512bb62a-calon
评论
PHP DOM Template
PHPDOMTemplate是一个快速的PHP模板引擎,下面是一个HelloWorld的例子:<?php// Start the output bufferob_start();?><
PHP DOM Template
0
Message Template
一个简单的短信模版应用。即为某个联系人制定好短信模版,加上联系人的手机好吗,之后直接点击这个联系人,就会跳转到设备发短信的界面,并且自动填充之前已经定制好的短息内容。Demo还可以读取设备的通讯录。[
Message Template
0
Ease Template
EaseTemplate模板能够改善网站的结构,其特点有:*可以在几秒钟改变整个站点的外观;*可以让网站更容易实现多语言;*抽象程序设计,没有垃圾HTML代码;*稳定性能初期的强大甚至超越混编代码;*
Ease Template
0
Template Toolkit
TemplateToolkit是一个快速、灵活和高可扩展的模板处理系统。可以用来处理各种规模的网页下面是Perl使用该工具的例子:模板文件内容:Dear[%name%],Ithascometooura
Template Toolkit
0
Python iOS Template
PythoniOSTemplate是构建可以在iOS上运行的Python应用模板。快速入门:安装cookiecutter:$ pip install cookiecutter在Python-iOSte
Python iOS Template
0