关于ASP程序调用模板的一些思考
帮朋友写一个图片程序,写了快三个月了,还没写好,也不知道天天忙什么,在此检讨一下。今天朋友又要了,555555555555555~
现在要加油了。前几天写到了模板导入导出功能(请参考我的文章:JSON在模板中的应用~http://www.miaoqiyuan.cn/p/json-template/),今天来说下关于ASP程序调用模板的一些思考。实际程序的模板方面功能没有很复杂,根据朋友的要求,把模板标签分为全局标签,局部标签。包含局部标签的定义为复杂标签,反之不包含的为简单标签,初步设定模板的简单标签如下:
{csims:sitename}
{csims:keyword}
{csims:description}
{csims:webpath}
{csims:copyright}复杂标签格式设定为{csims:标签标识,标签设定->输出格式},当然扩展性我认为还是不错的,举几个例子来说
{csims:menu->|<a href="$herf$">$name$</a>}
{csims:page,12-><a href="{csims:webpath}$pageurl$">$pageid$</a> }其中$xxx$是局部标签,他的定义需要根据各个复杂标签的标识符和数据库中的相关字段来定义。
理论是有了,下面说下模板的使用方法,该系统需要实用ASP来当服务器脚本,我写得一个例子如下:
< %@codepage=65001%> <!--#include file="../config/config.asp"--> <!--#include file="../config/conn.asp"--> < % set rs=conn.execute("select index from template where use=true") if not rs.eof then index_html=rs(0) else rs.close set rs=nothing set rs=conn.execute("select index from template") if not rs.eof then index_html=rs(0) else response.write "无法加载模板" end if end if index_html=replace(index_html,"{csims:sitename}","网站名称") index_html=replace(index_html,"{csims:keyword}","页面关键字") index_html=replace(index_html,"{csims:description}","页面描述") index_html=replace(index_html,"{csims:webpath}",webpath) index_html=replace(index_html,"{csims:copyright}","版权所有") set csimsRegExp=new regexp csimsRegExp.ignorecase=true csimsRegExp.global=true csimsRegExp.Pattern = "{csims:([^}]*)\-\>([^}]*)}" set cslists=csimsRegExp.execute(index_html) for each pptext in cslists csims_HTML="<p>标签:"&pptext.submatches(0)&"<br />"&vbCrlf csims_HTML=csims_HTML+"格式:"&pptext.submatches(1)&"</p>"&vbCrlf&vbCrlf index_html=replace(index_html,pptext,csims_HTML) next response.write index_html 'zz="{csims:menu-><a href="$herf$">$name$</a>}" %>
上面的程序比较粗糙,还没有写出解释局部变量的代码,但是思路是正确的,在次基础上继续修改应该是可行的。
好久没有写博客了,博客IP还剩四五十,哎。懒了~确实该反省下了。。。。。
ip四五十太少了,经常更新会多的
哈哈 是得反省下 我的IP是10几个 哈哈
呵呵,博客来多了也没什么意思。
很不错啊,还是要多优化代码这块,增强用户体验啊.