|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
专业性的服务。有的ASP商提供垂直型的应用服务,针对某一特定行业提供应用服务。代码分别|模板index.asp
-----------------------------------------------------------------------
<!--#includefile="templateclass.asp"-->
<%
Thisisthecodeusedtoloadanddisplaythetemplate.
Seehowcleanitis!!!:)
subgo()
dimoTemplate
setoTemplate=newtemplate
withoTemplate
.usetemplate("message.tpl")
.tag("date")=Date()
.tag("self")="<divstyle=background:#dddddd>"&.gettemplate("message.tpl",true)&"</div>"
.tag("aspcode")=.gettemplate("index.asp",false)
.tag("howtouse")=.gettemplate("howtouse.tpl",false)
.display()
endwith
setoTemplate=nothing
endsub
go()
%>
templateclass.asp
------------------------------------------------------------------------
<%
Thisisthetemplateobject.Itallowsthecreation,reading
andeditingoftemplatesontheserver.
CREATEDBY:ChristopherBrown-Floyd
DATE:November3,1999
classtemplate
Thisvariablestoresthetemplate
privatemytemplateasstring
Thismethodgetsatemplatefromtheserverandreturns
thewholefileasastring.
publicfunctiongettemplate(pathfilename,encodetohtml)asstring
dimoFSOasobject
dimoTemplateasobject
dimtemptemplateasstring
Opentypeforthetemplate(read-only)
constforreading=1,boolcreatefile=false
ifIsNull(encodetohtml)orencodetohtml=""orencodetohtml=falsethen
encodetohtml=false
else
encodetohtml=true
endif
onerrorresumenext
Createfilesystemobject
setoFSO=server.createobject("scripting.filesystemobject")
Createtemplateobject
setoTemplate=oFSO.opentextfile(server.mappath(pathfilename),forreading,boolcreatefile)
iferr0then
err.clear
exitfunction
endif
Getthewholefileasastring
temptemplate=oTemplate.readall
EncodetemplatetoHTML?
ifencodetohtmlthen
gettemplate=tohtml(temptemplate)
else
gettemplate=temptemplate
endif
Closethetemplate
oTemplate.close
Freetheserverresources
setoTemplate=nothing
setoFSO=nothing
endfunction
Thisproceduregetsandstoresatemplate
publicsubusetemplate(pathfilename)
thistemplate=gettemplate(pathfilename,false)
endsub
Thispropertyreplacestagswiththeuserstemplate
publicpropertylettag(tagname,userstring)
dimld,rdasstring
dimtemptagasstring
dimtagstart,tagendasinteger
ld=</p>缺点:正版成本价格贵(盗版就不说了)、不够安全,大多数服务器用windows系统,没有linux安全 |
|