模块文件生成html

来源:互联网 发布:wd移动硬盘格式化mac 编辑:程序博客网 时间:2024/04/30 20:39

<!–模块文件(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
%>

原创粉丝点击