ASP使用模板生成静态页面

读模板的操作,strModelFile是模板的名字

function readModel(strModelFile)
readModel = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if (fso.FileExists(Server.MapPath(strModelFile))) Then
Set fin = fso.OpenTextFile(Server.MapPath(strModelFile),1)
readModel = fin.readall
fin.close
set fin = nothing
end if
set fso = nothing
end function

这个是写要生成的静态页面,strHtmlFile这个是要生成页面的名字,strContent这个是生成页面的HTML

function writeHtml(strHtmlFile,strContent)
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")

'判断要放页面的文件夹是否存在,如果不存在就创建
if (FileObject.FolderExists("d:\mydrivers\web\products\html\")) then
else
FileObject.CreateFolder("d:\mydrivers\web\products\html\")
end if

'写文件,如果有就重写
Set openFile=FileObject.CreateTextFile(strHtmlFile,true) 'true重新写
openFile.writeline(strContent)
openFile.close
set FileObject=nothing
set openFile=nothing
end function


如果给你带来帮助,欢迎微信或支付宝扫一扫,赞一下。