通过模板生成静态页面示例
2004-12-24 14:38
281 查看
'/////////////////////////////////////////////////////
'通过模板生成静态页面示例
'作者: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
%>
'通过模板生成静态页面示例
'作者: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
%>
相关文章推荐
- 通过模板生成静态html页面示例
- java通过模板生成docx,docx再转pdf
- C#通过动态页面生成静态页面
- java代码通过freemarker模板实现自动生成dao,model,service,jsp
- 创建代码生成器可以很简单:如何通过T4模板生成代码?[下篇]
- asp.net 通过模板生成静态html
- Android Studio通过插件自动生成Pracelable的模板代码
- java poi通过模板生成word文档
- POI通过读取Excel模板生成Excel文件
- ThymeLeaf通过模板转换对象(根据模板和map生成)
- 利用POI生成Excel并通过Servlet下载示例
- 一起谈.NET技术,创建代码生成器可以很简单:如何通过T4模板生成代码?[上篇]
- 多语言网站生成静态页面实现思路以及用freemarker作模板生成静态页面的实现
- Spring 中 AbstractExcelView 支持根据模板生成Excel文件. 通过设置 view 的 URL 属性指定模板的路径
- html模板生成静态页面及模板分页处理
- 通过LS代码由一个ntf模板生成一个nsf
- 利用POI生成Excel并通过Servlet下载示例
- 一起谈.NET技术,创建代码生成器可以很简单:如何通过T4模板生成代码?[下篇]
- JAVA通过模板生成DOCX文档(2)
- 创建代码生成器可以很简单:如何通过T4模板生成代码?[下篇]