免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2151 | 回复: 3
打印 上一主题 下一主题

文档转换器兼模板引擎 TagFeather for php 里程碑版本 1.0.80 发布 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-28 23:53 |只看该作者 |倒序浏览
TagFeather 是一个文档转换器

这里也发一个吧, chinaunix 和 phpchina 是我常去的地方,有什么问题在这里和那边跟帖

原帖
http://bbs.phpchina.com/viewthre ... mp;extra=#pid520602

TagFeather里程碑版本 1.0.80 发布
TagFeather 又一个里程碑版本发布。
新版本,RC 稳定版本发布 版本号为  TagFeather1.0.80

现在服务端的前缀是 tf: 而不是 php: ,parser: 表明 TagFeather 是通用的文档转换器,不仅仅能用于 php
增加了安全模式。使得编译模板更安全
所有代码都有了单独中文文档。
所有服务端属性都有了文档。
增加了不少服务端属性
修正了原有服务端属性的 Bug
tf:wrap 代替了未经测试的 php:autowrap ,使得书写更自然。
修正了构造特殊属性使得解析器(TF_XmlParser)工作不正常
优化了程序结构,现在各类基本独立
现在有 41个服务端属性
下载地址
http://code.google.com/p/tagfeat ... &q=#makechanges
还是那句话:给我点信心,看有多少人关注。
文档地址:
http://www.tagfeather.com/doc/
google 镜像 http://tagfeather.googlecode.com/svn/trunk/doc/index.html
现在,代码上应该没 bug 了。 结构也很清晰,文档都给了。尽管不好看,但已经不是要深入代码才能看得懂的了。
自从7月以来我基本都是在写文档。
构架上已经不必修改了。
========保留的旧版本的分割线========
所见所得的模板引擎。美工的静态页面就是动态页面的模板。不必写什么奇怪的东西

临时做了个官方网站 www.tagfeather.com

这里有个 横排表格的示例 。 smarty 肯定没法实现所见所得。纯 php 代码也不能实现所见所得
http://www.tagfeather.com/t/tutorial/all.html

其他资料请看主页上的介绍,相比以前的 TagFeather 2008-1-30 版本,改进了不少。

下载地址
http://tagfeather.googlecode.com ... 1.0beta-build51.zip

我看看能统计到多少人。

讨论 QQ 群 : 61962996

论坛徽章:
0
2 [报告]
发表于 2008-07-29 00:06 |只看该作者
给这里的没见过的来一段代码吧

x.php: 代码文件,兼职配置文件
[php]
<?php
require_once('../TagFeather/translog.inc.php');
require_once('../TagFeather.php');
$l=7;
$col=3;
TagFeather:isplayAndExit("x.html",'x.php');

?>
<div tf:showstruct="no"><!-- you can try tf:showstruct="yes"-->
<table border="1">
        <tr        tf:selector=".x tr" tf:showonce="uuid_.x tr">
                <? for($i=0;$i<$col;$i++){//1?>
                        <th tf:wrap="pi" tf:selector=".x tr th" tf:showonce="uuid_.x tr th"><? echo $i+1;?>!!</th>
                <? }//1?>
        </tr>
        <?for($i=0;$i<$l;$i++){//2
                if($i % $col==0){ //3?>
        <tr        tf:wrap="pi" tf:wrap_mode="both" tf:selector=".x tr^2" tf:showonce="uuid_.x tr^2"
        ><?php }//3?>
                <td
                        tf:selector=".x tr>td"
                        tf:showonce=".x tr>td"
                        tf:bindas=".blanktd"
                        tf:bindas_mode="posttag"
                        style="border:1px solid black;"
                        >
                        【N】:<span tf:byvisible="【N】" tf:byvisible_reverse="yes" tf:notag="yes"><?=$i+1;?></span>
                </td>
                <?if($i+1==$l){$lastcol=$col- ($l % $col);for($j=0;$lastcol==$col,$j<$lastcol;$j++){//4 5?>
                <td class="blanktd"
                        tf:quick="yes"
                        tf:wrap="pi"
                        tf:showonce=".blanktd"
                        tf:bindto=".blanktd"
                        tf:bindto_mode="append"
                        align="right"
                > class="blanktd"
                </td>
                <?php }}//4 5 ?>
                <?if(($i+1) % $col ==0 || $i+1==$l){ //6?>
        </tr>
        <?        } //6
        }//4 ?>
</table>
</div>
[/php]
x.html : 输入文件
[php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>TagFather 主动测试</title>
</head>
<body>
<table border="1" class="x" style="width:100%">
        <tr>
                <th>a</th>
                <th>b</th>
                <th>c</th>
        </tr>
        <tr>
                <td>第<b>【N】</b>个元素</td>
                <td>你看不见我</td>
                <td>你看不见我</td>
        </tr>
        <tr>
                <td>第<b>【N】</b>个元素</td>
                <td>你看不见我</td>
                <td>你看不见我</td>
        </tr>
        <tr>
                <td>第<b>【N】</b>个元素</td>
                <td>你看不见我</td>
                <td>你看不见我</td>
        </tr>
        <tr>
                <td>你看不见我</td>
                <td class="blanktd" style="background:gray;color:white;">xxx</td>
                <td class="blanktd" style="background:gray;color:white;">efas</td>
                <td class="blanktd" style="background:gray;color:white;">abc</td>
                <td class="blanktd" style="background:gray;color:white;">!!!!</td>
        </tr>
</table>
</body>
</html>
[/php]
cache/x.cache.php 输出文件,前面一大段 php 注释可以设置为不输出的
[php]
<?php
//Cache By TagFeather Version $Id: TagFeather.class.php 79 2008-07-28 09:59:45Z dvaknheo $
//source x.html Time 2008-07-28 15:54:48 MD5 31c64825ced5f720df39d98a85fad3e1
//dest   x.cache.php Time 2008-07-28 16:00:19 MD5 b4ef2ebc5c4a5c5d66c8cb5b4e254b43
//(MD5 no include this server block)
//timecost:0.3653781414032
if(!$GLOBALS['TF_IN_CACHE']){exit('TagFeather:permission deny');}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>TagFather 主动测试</title>
</head>
<body>
<table border="1" class="x" style="width:100%">
        <tr>
                <? for($i=0;$i<$col;$i++){//1?><th>a</th><? }//1?>
               
               
        </tr>
        <?for($i=0;$i<$l;$i++){//2
                if($i % $col==0){ //3?><tr><?php }//3?>
                <td style="border:1px solid black;">第<?=$i+1;?>个元素</td><?if($i+1==$l){$lastcol=$col- ($l % $col);for($j=0;$lastcol==$col,$j<$lastcol;$j++){//4 5?><td class="blanktd" style="border:1px solid black;" align="right">xxx</td><?php }}//4 5 ?>
               
               
        <?if(($i+1) % $col ==0 || $i+1==$l){ //6?></tr><?        } //6
        }//4 ?>
       
       
       
</table>
</body>
</html>

[/php]
浏览器输出。
[php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>TagFather 主动测试</title>
</head>
<body>
<table border="1" class="x" style="width:100%">
        <tr>
                <th>a</th><th>a</th><th>a</th>               
               
        </tr>
        <tr>                <td style="border:1px solid black;">第1个元素</td>               
               
                        <td style="border:1px solid black;">第2个元素</td>               
               
                        <td style="border:1px solid black;">第3个元素</td>               
               
        </tr><tr>                <td style="border:1px solid black;">第4个元素</td>               
               
                        <td style="border:1px solid black;">第5个元素</td>               
               
                        <td style="border:1px solid black;">第6个元素</td>               
               
        </tr><tr>                <td style="border:1px solid black;">第7个元素</td><td class="blanktd" style="border:1px solid black;" align="right">xxx</td><td class="blanktd" style="border:1px solid black;" align="right">xxx</td>               
               
        </tr>       
       
       
</table>
</body>
</html>

float(0.49056792259216)

[/php]

论坛徽章:
0
3 [报告]
发表于 2008-07-29 00:23 |只看该作者
摘要:
把静态页面文件作为模板,通过可以和代码文件写在一起的配置文件,转成动态页面文件,以得到所见所得的效果
使用 SAX 解析。放弃了标签名称而是使用标签属性。

论坛徽章:
52
码神
日期:2017-03-28 10:27:10综合交流区版块每日发帖之星
日期:2015-10-11 06:20:00综合交流区版块每日发帖之星
日期:2015-09-28 06:20:00综合交流区版块每日发帖之星
日期:2015-09-22 06:20:00每日论坛发贴之星
日期:2015-09-12 06:20:00综合交流区版块每日发帖之星
日期:2015-09-12 06:20:00综合交流区版块每日发帖之星
日期:2015-09-08 06:20:00综合交流区版块每日发帖之星
日期:2015-09-05 06:20:00综合交流区版块每日发帖之星
日期:2015-09-04 06:20:002015亚冠之德黑兰石油
日期:2015-09-01 10:41:53每日论坛发贴之星
日期:2015-10-11 06:20:00综合交流区版块每日发帖之星
日期:2015-10-12 06:20:00
4 [报告]
发表于 2008-07-29 11:05 |只看该作者
谢谢啦。。。:wink:
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP