程序已经完成,文档还在撰写中。
特性:
现有的框架程序都是以程序员为主
在没用特殊编辑工具的时候 最多只能实现可见结构编辑而非可视化编辑
PhpServerTag 采用在 html 标签里添加特殊属性而不是修改html标签的方法
使得美工不再只见结构不见样式
简单的调用模式只要嵌入 3 行 php 代码
方便的扩展
Demo:
test3.php
<?php
require_once "phpservertag.inc.php";
pst_outcachestart();
echo'<title>new title</title>';
pst_outcacheend();
$str=pst_template();
if($str){include $str;return;}
?>
<html php:htmlbodywarp="yes" php:headfile="head.inc.php" php:footfile='foot.inc.php'>
<title>justtest</title>
<body>
<div php:for="$i" php:total="2" >
<center php:if="$i < 1">PHPSERVERTAG=PHPSERVERTAG;</center>
($i+1;)current php version phpversion();
<br php:posttag="<?php echo "done"?>" php:tag="hr">
</div>
</body>
如果 test3.cache.php 不存在或时间太小,则重新生成 test.cache.php 包含并返回
function pst_template($sourcePHP=false,$cachePHP=false);
生成的 源文件和目标文件可改
<?php if(!defined("PHPSERVERTAG"))die("permission deny");?><?php
require_once "phpservertag.inc.php";
pst_incache();
$str=pst_cache_template();
if($str){include $str;return;}
?><?php @include "head.inc.php";?>
<?php for($i=0;$i < 2;$i++){?><div>
<?php if($i < 1){ ?><center>PHPSERVERTAG=<?php echo PHPSERVERTAG?></center><?php }?>
(<?php echo $i+1?>)current php version <?php echo phpversion()?>
<hr /><?php echo "done"?>
</div><?php }?>
<?php @include "foot.inc.php";?>
用户访问的 test3.php 的输出内容
title 部分是 test3.php 的输出,其他部分是 test3.cache.php 的输出
<?php
<title>new title</title> <div>
<center>PHPSERVERTAG=0.2</center> (1)current php version 5.0.4 <hr />done </div><div>
(2)current php version 5.0.4 <hr />done </div>
?>
可扩展性
<?php
var $handles=array(
'init'=>array(),
'precompile'=>array(),
'postcompile'=>array(),
'prekey'=>array(),
'textcookie'=>array(),
'comment'=>array(),
'error'=>array()
);
?>
上述部分都可以扩展
最简单的,你可以建立函数如
function phptag_as(&$attrs,&$ps){}
对应 php:tag 的 html 标签属性
一些有用的开发信息
phptag_xx 是 php:xx 属性的实现函数
pst_xmlparser 是xml类
phpservertag 是 主类
pst_outcachestart pst_outcacheend 编译时将被替换成 pst_incache
所以保留这三个空函数
pst_template 将被替换为 pst_cache_template 并返回 false
你可以在 html 属性中使用 < ? ? > 但只能是开头和结尾,里面的字符串将不转化
客户端输出的 html 属性 也能使用 \xx; 来替换 <?= ?>
已知 Bug
\var
this; 不是返回母页的 $this 而是返回 当前的 PhpServerTag 实例