国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

首頁 > 編程 > ASP > 正文

ASP 高級模板引擎實現類

2024-05-04 11:08:43
字體:
來源:轉載
供稿:網友
這個模板引擎比較方便,跟HTML結合了
 
 
 
復制代碼代碼如下:

Class template 

Private c_Char, c_Path, c_FileName, c_Content, c_PageUrl, c_CurrentPage, c_PageStr, ReplacePageStr 
Private TagName 

' *************************************** 
' 設置編碼 
' *************************************** 
Public Property Let Char(ByVal Str) 
c_Char = Str 
End Property 
Public Property Get Char 
Char = c_Char 
End Property 

' *************************************** 
' 設置模板文件夾路徑 
' *************************************** 
Public Property Let Path(ByVal Str) 
c_Path = Str 
End Property 
Public Property Get Path 
Path = c_Path 
End Property 

' *************************************** 
' 設置模板文件名 
' *************************************** 
Public Property Let FileName(ByVal Str) 
c_FileName = Str 
End Property 
Public Property Get FileName 
FileName = c_FileName 
End Property 

' *************************************** 
' 獲得模板文件具體路徑 
' *************************************** 
Public Property Get FilePath 
If Len(Path) > 0 Then Path = Replace(Path, "/", "/") 
If Right(Path, 1) <> "/" Then Path = Path & "/" 
FilePath = Path & FileName 
End Property 

' *************************************** 
' 設置分頁URL 
' *************************************** 
Public Property Let PageUrl(ByVal Str) 
c_PageUrl = Str 
End Property 
Public Property Get PageUrl 
PageUrl = c_PageUrl 
End Property 

' *************************************** 
' 設置分頁 當前頁 
' *************************************** 
Public Property Let CurrentPage(ByVal Str) 
c_CurrentPage = Str 
End Property 
Public Property Get CurrentPage 
CurrentPage = c_CurrentPage 
End Property 

' *************************************** 
' 輸出內容 
' *************************************** 
Public Property Get Flush 
Response.Write(c_Content) 
End Property 

' *************************************** 
' 類初始化 
' *************************************** 
Private Sub Class_Initialize 
TagName = "pjblog" 
c_Char = "UTF-8" 
ReplacePageStr = Array("", "") 
End Sub 

' *************************************** 
' 過濾沖突字符 
' *************************************** 
Private Function doQuote(ByVal Str) 
doQuote = Replace(Str, Chr(34), """) 
End Function 

' *************************************** 
' 類終結 
' *************************************** 
Private Sub Class_Terminate 
End Sub 

' *************************************** 
' 加載文件方法 
' *************************************** 
Private Function LoadFromFile(ByVal cPath) 
Dim obj 
Set obj = Server.CreateObject("ADODB.Stream") 
With obj 
.Type = 2 
.Mode = 3 
.Open 
.Charset = Char 
.Position = .Size 
.LoadFromFile Server.MapPath(cPath) 
LoadFromFile = .ReadText 
.close 
End With 
Set obj = Nothing 
End Function 

' *********************************************** 
' 獲取正則匹配對象 
' *********************************************** 
Public Function GetMatch(ByVal Str, ByVal Rex) 
Dim Reg, Mag 
Set Reg = New RegExp 
With Reg 
.IgnoreCase = True 
.Global = True 
.Pattern = Rex 
Set Mag = .Execute(Str) 
If Mag.Count > 0 Then 
Set GetMatch = Mag 
Else 
Set GetMatch = Server.CreateObject("Scripting.Dictionary") 
End If 
End With 
Set Reg = nothing 
End Function 

' *************************************** 
' 打開文檔 
' *************************************** 
Public Sub open 
c_Content = LoadFromFile(FilePath) 
End Sub 

' *************************************** 
' 緩沖執行 
' *************************************** 
Public Sub Buffer 
c_Content = GridView(c_Content) 
Call ExecuteFunction 
End Sub 

' *************************************** 
' GridView 
' *************************************** 
Private Function GridView(ByVal o_Content) 
Dim Matches, SubMatches, SubText 
Dim Attribute, Content 
Set Matches = GetMatch(o_Content, "/<" & TagName & "/:(/d+?)(.+?)/>([/s/S]+?)<//" & TagName & "/:/1/>") 
If Matches.Count > 0 Then 
For Each SubMatches In Matches 
Attribute = SubMatches.SubMatches(1) ' kocms 
Content = SubMatches.SubMatches(2) ' <Columns>...</Columns> 
SubText = Process(Attribute, Content) ' 返回所有過程執行后的結果 
o_Content = Replace(o_Content, SubMatches.value, "<" & SubText(2) & SubText(0) & ">" & SubText(1) & "</" & SubText(2) & ">", 1, -1, 1) ' 替換標簽變量 
Next 
End If 
Set Matches = Nothing 
If Len(ReplacePageStr(0)) > 0 Then ' 判斷是否標簽變量有值,如果有就替換掉. 
o_Content = Replace(o_Content, ReplacePageStr(0), ReplacePageStr(1), 1, -1, 1) 
ReplacePageStr = Array("", "") ' 替換后清空該數組變量 
End If 
GridView = o_Content 
End Function 

' *************************************** 
' 確定屬性 
' *************************************** 
Private Function Process(ByVal Attribute, ByVal Content) 
Dim Matches, SubMatches, Text 
Dim MatchTag, MatchContent 
Dim datasource, Name, Element, page, id 
datasource = "" : Name = "" : Element = "" : page = 0 : id = "" 
Set Matches = GetMatch(Attribute, "/s(.+?)/=/""(.+?)/""") 
If Matches.Count > 0 Then 
For Each SubMatches In Matches 
MatchTag = SubMatches.SubMatches(0) ' 取得屬性名 
MatchContent = SubMatches.SubMatches(1) ' 取得屬性值 
If Lcase(MatchTag) = "name" Then Name = MatchContent ' 取得name屬性值 
If Lcase(MatchTag) = "datasource" Then datasource = MatchContent' 取得datasource屬性值 
If Lcase(MatchTag) = "element" Then Element = MatchContent ' 取得element屬性值 
If Lcase(MatchTag) = "page" Then page = MatchContent ' 取得page屬性值 
If Lcase(MatchTag) = "id" Then id = MatchContent ' 取得id屬性值 
Next 
If Len(Name) > 0 And Len(MatchContent) > 0 Then 
Text = Analysis(datasource, Name, Content, page, id) ' 執行解析屬性 
If Len(datasource) > 0 Then Attribute = Replace(Attribute, "datasource=""" & datasource & """", "") 
If page > 0 Then Attribute = Replace(Attribute, "page=""" & page & """", "") 
Attribute = Replace(Attribute, "name=""" & Name & """", "", 1, -1, 1) 
Attribute = Replace(Attribute, "element=""" & Element & """", "", 1, -1, 1) 
Process = Array(Attribute, Text, Element) 
Else 
Process = Array(Attribute, "", "div") 
End If 
Else 
Process = Array(Attribute, "", "div") 
End If 
Set Matches = Nothing 
End Function 

' *************************************** 
' 解析 
' *************************************** 
Private Function Analysis(ByVal id, ByVal Name, ByVal Content, ByVal page, ByVal PageID) 
Dim Data 
Select Case Lcase(Name) ' 選擇數據源 
Case "loop" Data = DataBind(id, Content, page, PageID) 
Case "for" Data = DataFor(id, Content, page, PageID) 
End Select 
Analysis = Data 
End Function 

' *************************************** 
' 綁定數據源 
' *************************************** 
Private Function DataBind(ByVal id, ByVal Content, ByVal page, ByVal PageID) 
Dim Text, Matches, SubMatches, SubText 
Execute "Text = " & id & "(1)" ' 加載數據源 
Set Matches = GetMatch(Content, "/<Columns/>([/s/S]+)/<//Columns/>") 
If Matches.Count > 0 Then 
For Each SubMatches In Matches 
SubText = ItemTemplate(SubMatches.SubMatches(0), Text, page, PageID)' 執行模塊替換 
Content = Replace(Content, SubMatches.value, SubText, 1, -1, 1) 
Next 
DataBind = Content 
Else 
DataBind = "" 
End If 
Set Matches = Nothing 
End Function 

' *************************************** 
' 匹配模板實例 
' *************************************** 
Private Function ItemTemplate(ByVal TextTag, ByVal Text, ByVal page, ByVal PageID) 
Dim Matches, SubMatches, SubMatchText 
Dim SecMatch, SecSubMatch 
Dim i, TempText 
Dim TextLen, TextLeft, TextRight 
Set Matches = GetMatch(TextTag, "/<ItemTemplate/>([/s/S]+)/<//ItemTemplate/>") 
If Matches.Count > 0 Then 
For Each SubMatches In Matches 
SubMatchText = SubMatches.SubMatches(0) 
' --------------------------------------------- 
' 循環嵌套開始 
' --------------------------------------------- 
SubMatchText = GridView(SubMatchText) 
' --------------------------------------------- 
' 循環嵌套結束 
' --------------------------------------------- 
If UBound(Text, 1) = 0 Then 
TempText = "" 
Else 
TempText = "" 
' ----------------------------------------------- 
' 開始分頁 
' ----------------------------------------------- 
If Len(page) > 0 And page > 0 Then 
If Len(CurrentPage) = 0 Or CurrentPage = 0 Then CurrentPage = 1 
TextLen = UBound(Text, 2) 
TextLeft = (CurrentPage - 1) * page 
TextRight = CurrentPage * page - 1 
If TextLeft < 0 Then TextLeft = 0 
If TextRight > TextLen Then TextRight = TextLen 
c_PageStr = MultiPage(TextLen + 1, page, CurrentPage, PageUrl, "float:right", "", False) 

If Int(Len(c_PageStr)) > 0 Then 
ReplacePageStr = Array("<page:" & Trim(PageID) & "/>", c_PageStr) 
Else 
ReplacePageStr = Array("<page:" & Trim(PageID) & "/>", "") 
End If 
Else 
TextLeft = 0 
TextRight = UBound(Text, 2) 
End If 

For i = TextLeft To TextRight 
TempText = TempText & ItemReSec(i, SubMatchText, Text) ' 加載模板內容 
Next 
End If 
Next 
ItemTemplate = TempText 
Else 
ItemTemplate = "" 
End If 
Set Matches = Nothing 
End Function 

' *************************************** 
' 替換模板字符串 
' *************************************** 
Private Function ItemReSec(ByVal i, ByVal Text, ByVal Arrays) 
Dim Matches, SubMatches 
Set Matches = GetMatch(Text, "/$(/d+?)") 
If Matches.Count > 0 Then 
For Each SubMatches In Matches 
Text = Replace(Text, SubMatches.value, doQuote(Arrays(SubMatches.SubMatches(0), i)), 1, -1, 1) '執行替換 
Next 
ItemReSec = Text 
Else 
ItemReSec = "" 
End If 
Set Matches = Nothing 
End Function 

' *************************************** 
' 全局變量函數 
' *************************************** 
Private Sub ExecuteFunction 
Dim Matches, SubMatches, Text, ExeText 
Set Matches = GetMatch(c_Content, "/<function/:([0-9a-zA-Z_/.]*?)/((.*?)/""(.+?)/""(.*?)/)///>") 
If Matches.Count > 0 Then 
For Each SubMatches In Matches 
Text = SubMatches.SubMatches(0) & "(" & SubMatches.SubMatches(1) & """" & SubMatches.SubMatches(2) & """" & SubMatches.SubMatches(3) & ")" 
Execute "ExeText=" & Text 
c_Content = Replace(c_Content, SubMatches.value, ExeText, 1, -1, 1) 
Next 
End If 
Set Matches = Nothing 
End Sub 

' *************************************** 
' 普通替換全局標簽 
' *************************************** 
Public Property Let Sets(ByVal t, ByVal s) 
Dim SetMatch, Bstr, SetSubMatch 
Set SetMatch = GetMatch(c_Content, "(/<Set/:([0-9a-zA-Z_/.]*?)/(((.*?)" & t & "(.*?))?/)///>)") 
If SetMatch.Count > 0 Then 
For Each SetSubMatch In SetMatch 
Execute "Bstr = " & SetSubMatch.SubMatches(1) & "(" & SetSubMatch.SubMatches(3) & """" & s & """" & SetSubMatch.SubMatches(4) & ")" 
c_Content = Replace(c_Content, SetSubMatch.Value, Bstr, 1, -1, 1) 
Next 
End If 
Set SetMatch = Nothing 
Set SetMatch = GetMatch(c_Content, "(/<Set/:" & t & "///>)") 
If SetMatch.Count > 0 Then 
For Each SetSubMatch In SetMatch 
c_Content = Replace(c_Content, SetSubMatch.Value, s, 1, -1, 1) 
Next 
End If 
Set SetMatch = Nothing 
End Property 

End Class

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
超碰人人在线| 中文字幕一区二区三区免费视频| 99在线播放| 在线中文av| www.xxx黄| 九九热免费在线视频| 天天操中文字幕视频| 久热免费在线视频| 天天操天天操天天色天天要| 国产卡二和卡三的视频| 国产永久免费高清在线观看视频 | 国内自拍视频在线观看| 国产在线高潮| 国产美女视频一区二区三区 | 久久91精品视频| 国产黄色免费看| 九色视频网站| 午夜在线网站| av免费在线播放| 中文字幕麻豆| 99中文字幕一区| 午夜伦全在线观看| 日本综合一区二区三区| 国产成人午夜| 国产一二在线观看| 毛片在线视频| www.xxx黄| 精品街拍一区二区| 国产精品入口免费麻豆| 国产在线视频网站| 日本高清不卡中文字幕| 中文字幕4区| 国产精品美女视频免费观看软件| 中文产幕区在线观看| 国产一级二级在线| 国产美女高潮| 老司机精品视频一区二区| 亚洲精品一区中文字幕电影| 国产午夜视频| 国产一二三区在线观看| 成人精品福利| 日韩av成人| 国产一级粉嫩xxxx| 国产三级在线观看| 国产激情自拍| 国产精品视频一区二区三区麻豆 | 国产专区在线| 四虎国产精品永久| 爱福利在线视频| 本道综合精品| 九九热在线播放| 中文字幕在线影院| 中文字幕成人乱码在线电影| 国产一级黄色电影| 精品女厕厕露p撒尿| 91青青在线视频| 亚洲videos| 最近中文字幕mv2018在线高清| 免费三级毛片| 狂野欧美性猛交xxxx乱大交| 高清欧美精品xxxxx在线看| 中文字幕日本在线观看| 国产二级片在线| 任你操视频在线观看| 中文字幕久热在线精品| 国产三级在线| eeuss影院网站免费观看| 欧美日韩一区二区三区视视频| 六月天色婷婷| 国产成人福利| 黄色激情网址| 国产对白在线| 国产麻豆一级片| 国产福利小视频在线| 日本一级理论片在线大全| 国产精品自拍亚洲| 91美女在线| 国产女主播在线| 黄色激情网址| 天天插天天操| 国产成人va亚洲电影| 国产中文伊人| xxxxx中文字幕| 国产成人精品综合网站| 久热精品免费视频| 91精品大全| 国产视频第一区| 久久久久久日本一区99| 91精选福利| 国产一区二区三区福利| 久热精品视频在线播放| av在线free| av人人综合网| 在线国产91| av高清在线| 91麻豆精品国产91久久| 中文字幕在线观看播放| 九九视频在线播放| 免费国产在线视频| аⅴ成人天堂中文在线| 亚洲精品视频区| 亚洲综合在线免费| 中文字幕av网| 在线播放av网站| 一本久中文高清| 在线看黄网站| www狠狠操| 好吊日视频在线观看| 久久五月精品| 日本中文字幕在线观看| 国产无遮挡又黄又爽免费网站| 国产九九九九| 国产一二三区在线观看| 国产福利资源| eeuss影影院www在线播放| 人人干人人插| 国产免费福利| 91精品专区| www.久草.com| 老司机精品视频一区二区| 免费观看一二区视频网站| 久热中文字幕在线观看| 久热国产在线| 国产福利电影在线观看| 亚洲尤物在线视频| 国产在线观看网站| 国产h在线观看| h网址在线观看| 国产亚洲精品自在线观看| 国产不卡在线| 免费观看久久久久| 国产青草视频在线观看视频| 在线观看精品一区二区三区| 久久99亚洲网美利坚合众国| 91福利在线免费| 日本调教视频在线观看| 国产呻吟对白刺激无套视频在线| av亚洲男人天堂| 国产网站免费观看| www在线播放| 69视频在线观看| 国产伦精品一区二区三区高清版禁 | 在线播放www| 国产一级粉嫩xxxx| 久草.com| 亚洲视频日韩| 国产wwww| 91在线高清| 国产高潮av| 国产精品黄页网站在线播放免费| 狠狠干天天干| 超碰在线影院| www免费在线观看| av在线二区| 在线免费观看黄色av| 国产视频资源| 国产一级片在线| 日本中文字幕视频在线| 高清在线观看av| 狠狠操狠狠色| 超碰在线网址| 国产理论片免费观看| 国产在线一二| 国产网站免费观看| 国产超碰在线| 99精品老司机免费视频| 97高清视频| 亚洲私人影吧| www久久日com| 国产中文字幕第一页| 天天操天天艹| 精品一区二区三区在线成人| 精品国产免费第一区二区| 精品国产二区三区| 亚洲国产精品区| 香蕉视频在线看| 国产中文第一页| 国产精品视频福利一区二区| 国产第一页在线视频| 伊人春色在线| 国产在线中文字幕| 国产无遮挡又黄又爽免费软件 | 国产高清自拍视频在线观看| 国产对白国语对白| 日p在线观看| 国产亚洲精品拍拍拍拍拍| 国产啊啊啊视频在线观看| 国产福利资源| 九九精品视频在线观看九九| 国产人成在线观看| www.狠狠色.com| 国产成人精品男人的天堂538| jizz性欧美| 国产视频1区| 美女免费视频黄| 国产精品yjizz视频网一二区| 91视频久色| 国产麻豆一级片| jizz在线视频| 伊人电影在线观看|