eover

通过模板生成静态html页面示例 

--------------------------------------------------------------------------------
 
日期:2005-6-16 8:36:45 来源:来自网络 查看:[大 中 小] 作者:不详 热度:5
\'/////////////////////////////////////////////////////
\'通过模板生成静态页面示例
\'作者:griefforyou
\'/////////////////////////////////////////////////////

<!--模块文件(template.htm)-->
<html>
<head>
<title>%TITLE%</title>
</head>
<body>
%CONTENT%
</body>
</html>

<!--TestTemplate.asp-->
<%
Dim fso,f
Dim strTitle,strContent,strOut
\'创建文件系统对象
Set fso=Server.CreateObject("Scripting.FileSystemObject")

\'打开网页模板文件,读取模板内容
Set f=fso.OpenTextFile(Server.MapPath("Template.htm"))
strOut=f.ReadAll
f.close

strTitle="这是生成的网页标题"
strContent="这是生成的网页内容"

\'用真实内容替换模板中的标记
strOut=Replace(strOut,"%TITLE%",strTitle)
strOut=Replace(strOut,"%CONTENT%",strContent)

\'创建要生成的静态页
Set f=fso.CreateTextFile(Server.MapPath("New.htm"),true)

\'写入网页内容
f.WriteLine strOut
f.close

Response.Write "生成静态页成功!"

\'释放文件系统对象
set f=Nothing
set fso=Nothing
%>
 

分类:

技术点:

相关文章: