Parameter description
'Template used by demoname [../demo/*.html]
'savename save location and name [../demo/*.html]
'strflag Flag to be replaced [$aaa$,$bbb$]
'strcontent Replacement content of each tag [aaa$bbb]
'================================================== ============================
Sub makepage(demoname,savename,strflag,strcontent)
Dim fso,htmlwrite
Dim strOut
'//Create file system object Set fso=Server.CreateObject(Scripting.FileSystemObject)
'//Open the web page template file and read the template content
Set htmlwrite=fso.OpenTextFile(Server.MapPath(demoname))
strOut=htmlwrite.ReadAll
htmlwrite.close
'================================================== ============================
strflag=split(strflag,,)
for i = 0 to ubound(strflag)
strcont=split(strcontent,$)
strOut=Replace(strOut,strflag(i),strcont(i))
'response.write strflag(i)&=&[&strcont(i)&]
next
'// Replace tags in template with real content
'================================================== ============================
'//Create the static page to be generated
Set htmlwrite=fso.CreateTextFile(Server.MapPath(savename),true)
'//Write web page content
htmlwrite.WriteLine strOut
htmlwrite.close
Response.Write
'// Release the file system object
sethtmlwrite=Nothing
set fso=Nothing
end sub
-------------------------------------------------- -------------------------------------------------- ----------------------------------------
Usage example:
'Replace tag
commentFlag=$hotname$,$webkeywords$,$webdescription$,$webtitle$,$weblogo$
'Replace the value corresponding to the label
Hostname=Request.ServerVariables(SERVER_NAME)'Get the current domain name
set rs=conn.execute(select webtitle_cn,webkey_cn,webDescription_cn,weblogo,webbanner from [WebConfig])
commentstr=Hostname&$&rs(1)&$&rs(2)&$&rs(0)&$&rs(3)
rs.close
set rs=nothing
'Call subroutine
call makepage(../Demo/index_cn.html,../Cn/index.html,commentFlag,commentstr)