快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

申博app怎么下载_机器人论坛网



index.asp

-----------------------------------------------------------------------

templateclass.asp

------------------------------------------------------------------------

0 then

err.clear

exit function

end if

' Get the whole file as a string

temptemplate = oTemplate.readall

' Encode template to HTML?

if encodetohtml then

gettemplate = tohtml(temptemplate)

else

gettemplate = temptemplate

end if

' Close the template

oTemplate.close

' Free the server resources

set oTemplate = nothing

set oFSO = nothing

end function

' This procedure gets and stores a template

public sub usetemplate(pathfilename)

thistemplate = gettemplate(pathfilename,false)

end sub

' This property replaces tags with the user's template

public property let tag(tagname,userstring)

dim ld, rd 'as string

dim temptag 'as string

dim tagstart, tagend 'as integer

ld = ""

tagstart = 1

do while tagstart > 0 and tagstart0 then

tagend = instr(tagstart,thistemplate,rd)

if tagend > (tags申博app怎么下载tart + 3) then

temptag = mid(thistemplate,tagstart + 4,tagend-(tagstart+4))

if申博app怎么下载 (trim(temptag) = tagname) or (temptag = tagname) then

if IsNull(userstring) then

thistemplate = replace(thistemplate,ld & temptag & rd,"")

else

thistemplate = replace(thistemplate,ld & temptag & rd,userstring)

end if

exit do

else

tagstart = tagstart + 4

end if

end if

end if

loop

end property

public sub removeTags()

dim ld, rd 'as string

dim tem申博app怎么下载ptag 'as string

dim tagstart, tagend 'as integer

ld = ""

tagstart = 1

do while tagstart > 0 and tagstart0 then

tagend = instr(tagstart,thistemplate,rd)

if tagend > (tagstart + 3) then

temptag = mid(thistemplate,tagstart + 4,tagend-(tagstart+4))

thistemplate = replace(thistemplate,ld & temptag & rd,"")

tagstart = tagend

end if

end if

loop

end sub

' This property allows the user to assign the current template

public property let thistemplate(template_as_string)

if vartype(template_as_string) = vbstring _

or vartype(template_as_string) = vbnull then

mytemplate = template_as_string

end if

end property

' This property returns the current template

public property get thistemplate() 'as string

thistemplate = mytemplate

end property

' This subroutine displays the current template

public sub display()

response.write thistemplate

end sub

' This subroutine encodes the current template to HTML

public sub htmlencode()

tohtml(thistemplate)

end sub

' This procedure saves the current template to the server

public sub saveas(pathfilename)

dim oFSO 'as object

dim oTemplate,oBackup 'as object

dim strTruePath 'as string

' Open type for the template(read-only)

const forreading = 1,forwriting = 2,boolcreatefile = true

on error resume next

' Create filesystemobject

set oFSO = server.createobject("scripting.filesystemobject")

' Create template object

strTruePath = server.mappath(pathfilename)

if oFSO.fileexists(strTruePath) then

oFSO.copyfile strTruePath, strTruePath & ".bak", true

en申博app怎么下载d if

set oTemplate = oFSO.opentextfile(strTruePath,forwriting,boolcreatefile)

if 申博app怎么下载err

howtouse.tpl

------------------------------------------------------------------------

Object's properties:

thistemplate = String

Loads a dynamically built template into the template object. Use this method

when there isn't a file to read from.

Object's procedures:

tag(tag name as string) = String

WordStrs all occurrences of a tag within the current template with the specified string.

variable = gettemplate(path as string,[encode to html] as boolean)

Returns the template from the specified path; however, it isn't loaded into the object.

Object's methods:

usetemplate(path as string)

Loads the template from the specified path into the object.

htmlencode()

Encodes the current template loaded into HTML.

display()

Writes the current template to the user's browser.

removetags()

Removes all tags that haven't been replaced.

saveas(path as html)

Saves the current template to the specified path. Use this method when you

want to save the changes made to the template.

NOTE: If a file of the same name exists at the specified path, ".bak" will be

added to the end of its name; thus "myfile.tpl" would become "myfile.tpl.bak".

message.tpl

------------------------------------------------------------------------

This is an example of how to use my template class.

Dynamic data for your template can come from anywhere.

It can come from a built-in ASP function:

It can come from a file:

You can even use it as an online source editing tool for your ASP code:

NOTE: Templates can't have any ASP code in them. It'll only process HTML.

This is good practice, because it produces cleaner code and HTML.

盼望能对你有所赞助!

您可能还会对下面的文章感兴趣: