Mesin template ini lebih nyaman . Dikombinasikan dengan HTML.
Templat kelas
C_Char pribadi, c_Path, c_FileName, c_Content, c_PageUrl, c_CurrentPage, c_PageStr, GantiPageStr
Nama Tag Pribadi
' ***************************************
'Setel pengkodean
' ***************************************
Properti Umum Biarkan Char(ByVal Str)
c_Char = Str
Properti Akhir
Properti Umum Dapatkan Char
Karakter = c_Char
Properti Akhir
' ***************************************
'Tetapkan jalur folder templat
' ***************************************
Properti Umum Biarkan Jalur (ByVal Str)
c_Jalur = Str
Properti Akhir
Jalur Dapatkan Properti Umum
Jalur = c_Jalur
Properti Akhir
' ***************************************
'Tetapkan nama file templat
' ***************************************
Properti Publik Biarkan Nama File (ByVal Str)
c_NamaFile = Str
Properti Akhir
Properti Publik Dapatkan Nama File
Nama File = c_Nama File
Properti Akhir
' ***************************************
' Dapatkan jalur spesifik dari file templat
' ***************************************
Properti Publik Dapatkan FilePath
Jika Len(Path) > 0 Maka Path = Ganti(Path, /, /)
Jika Benar(Jalur, 1) <> / Maka Jalur = Jalur & /
FilePath = Jalur & Nama File
Properti Akhir
' ***************************************
'Setel URL halaman
' ***************************************
Properti Publik Biarkan PageUrl(ByVal Str)
c_PageUrl = Str
Properti Akhir
Properti Publik Dapatkan PageUrl
PageUrl = c_PageUrl
Properti Akhir
' ***************************************
'Setel paging halaman saat ini
' ***************************************
Properti Publik Biarkan Halaman Saat Ini (ByVal Str)
c_Halaman Saat Ini = Str
Properti Akhir
Properti Umum Dapatkan Halaman Saat Ini
Halaman Saat Ini = c_Halaman Saat Ini
Properti Akhir
' ***************************************
'Konten keluaran
' ***************************************
Properti Umum Dapatkan Flush
Respon.Tulis(c_Content)
Properti Akhir
' ***************************************
'Inisialisasi kelas
' ***************************************
Sub Kelas Pribadi_Inisialisasi
Nama Tag = pjblog
c_Char = UTF-8
GantiPageStr = Array(, )
Akhiri Sub
' ***************************************
' Filter karakter yang bertentangan
' ***************************************
Fungsi Pribadi doQuote(ByVal Str)
doQuote = Ganti(Str, Chr(34), )
Fungsi Akhir
' ***************************************
' Pemberhentian kelas
' ***************************************
Sub Kelas Pribadi_Terminate
Akhiri Sub
' ***************************************
'Memuat metode file
' ***************************************
Fungsi Pribadi LoadFromFile(ByVal cPath)
Objek redup
Setel obj = Server.CreateObject(ADODB.Stream)
Dengan objek
.Jenis = 2
.Modus = 3
.Membuka
.Charset = Karakter
.Posisi = .Ukuran
.LoadFromFile Server.MapPath(cPath)
LoadFromFile = .BacaTeks
.menutup
Akhiri Dengan
Tetapkan objek = Tidak ada
Fungsi Akhir
'***************************************************
' Dapatkan objek pencocokan biasa
'***************************************************
Fungsi Publik GetMatch(ByVal Str, ByVal Rex)
Redupkan Reg, Mag
Tetapkan Reg = RegExp Baru
Dengan Reg
.IgnoreCase = Benar
.Global=Benar
.Pola = Rex
Atur Mag = .Execute(Str)
Jika Mag.Count > 0 Maka
Setel GetMatch = Mag
Kalau tidak
Setel GetMatch = Server.CreateObject(Scripting.Dictionary)
Akhiri Jika
Akhiri Dengan
Setel Reg = tidak ada
Fungsi Akhir
' ***************************************
'Buka dokumen
' ***************************************
Sub Umum terbuka
c_Content = LoadFromFile(Jalur File)
Akhiri Sub
' ***************************************
'Eksekusi yang disangga
' ***************************************
Sub Buffer Publik
c_Konten = GridView(c_Konten)
Panggil ExecuteFunction
Akhiri Sub
' ***************************************
'Tampilan Grid
' ***************************************
Fungsi Pribadi GridView(ByVal o_Content)
Redupkan Kecocokan, Sub Cocok, SubTeks
Atribut Redup, Konten
Setel Kecocokan = GetMatch(o_Content, /< & TagName & /:(/d+?)(.+?)/>([/s/S]+?)<// & TagName & /:/1/>)
Jika Cocok. Hitung > 0 Lalu
Untuk Setiap Sub Pertandingan Dalam Pertandingan
Atribut = SubMatches.SubMatches(1) ' kocms
Isi = SubMatches.SubMatches(2) ' <Kolom>...</Kolom>
SubTeks = Proses(Atribut, Konten) 'Kembalikan hasil seluruh eksekusi proses
o_Content = Ganti(o_Content, SubMatches.value, < & SubTeks(2) & SubTeks(0) & > & SubTeks(1) & </ & SubTeks(2) & >, 1, -1, 1) ' Ganti variabel label
Berikutnya
Akhiri Jika
Tetapkan Kecocokan = Tidak Ada
Jika Len(ReplacePageStr(0)) > 0 Maka ' Tentukan apakah variabel label mempunyai nilai, dan gantilah jika ada.
o_Content = Ganti(o_Content, GantiPageStr(0), GantiPageStr(1), 1, -1, 1)
GantiPageStr = Array(, ) 'Hapus variabel array setelah penggantian
Akhiri Jika
GridView = o_Konten
Fungsi Akhir
' ***************************************
' Tentukan atribut
' ***************************************
Proses Fungsi Pribadi (Atribut ByVal, Konten ByVal)
Kecocokan Redup, SubPertandingan, Teks
Redupkan MatchTag, MatchContent
Redupkan sumber data, Nama, Elemen, halaman, id
sumber data = : Nama = : Elemen = : halaman = 0 : id =
Setel Kecocokan = GetMatch(Atribut, /s(.+?)/=/(.+?)/)
Jika Cocok. Hitung > 0 Lalu
Untuk Setiap Sub Pertandingan Dalam Pertandingan
MatchTag = SubMatches.SubMatches(0) ' Dapatkan nama atribut
MatchContent = SubMatches.SubMatches(1) ' Dapatkan nilai atribut
Jika Lcase(MatchTag) = nama Kemudian Nama = MatchContent ' Dapatkan nilai atribut nama
Jika Lcase(MatchTag) = sumber data Maka sumber data = MatchContent' Dapatkan nilai atribut sumber data
Jika Lcase(MatchTag) = elemen Kemudian Elemen = MatchContent ' Dapatkan nilai atribut elemen
Jika Lcase(MatchTag) = page Then page = MatchContent ' Dapatkan nilai atribut halaman
Jika Lcase(MatchTag) = id Kemudian id = MatchContent ' Dapatkan nilai atribut id
Berikutnya
Jika Len(Nama) > 0 Dan Len(MatchContent) > 0 Lalu
Teks = Analisis(sumber data, Nama, Konten, halaman, id) 'Lakukan penguraian properti
Jika Len(sumber data) > 0 Maka Atribut = Ganti(Atribut, sumber data= & sumber data & , )
Jika halaman > 0 Maka Atribut = Ganti(Atribut, halaman= & halaman &, )
Atribut = Ganti(Atribut, nama= & Nama & , , 1, -1, 1)
Atribut = Ganti(Atribut, elemen= & Elemen & , , 1, -1, 1)
Proses = Array (Atribut, Teks, Elemen)
Kalau tidak
Proses = Array(Atribut, , div)
Akhiri Jika
Kalau tidak
Proses = Array(Atribut, , div)
Akhiri Jika
Tetapkan Kecocokan = Tidak Ada
Fungsi Akhir
' ***************************************
' Mengurai
' ***************************************
Analisis Fungsi Pribadi (ID ByVal, Nama ByVal, Konten ByVal, halaman ByVal, PageID ByVal)
Data redup
Pilih Kasus Lcase(Nama) 'Pilih sumber data
Data perulangan kasus = DataBind(id, Konten, halaman, PageID)
Kasus untuk Data = DataFor(id, Konten, halaman, PageID)
Pilihan Akhir
Analisis=Data
Fungsi Akhir
' ***************************************
'Ikat sumber data
' ***************************************
DataBind Fungsi Pribadi (ID ByVal, Konten ByVal, halaman ByVal, PageID ByVal)
Redupkan Teks, Kecocokan, SubPertandingan, SubTeks
Jalankan Teks = & id & (1) 'Muat sumber data
Setel Kecocokan = GetMatch(Konten, /<Kolom/>([/s/S]+)/<//Kolom/>)
Jika Cocok. Hitung > 0 Lalu
Untuk Setiap Sub Pertandingan Dalam Pertandingan
SubTeks = ItemTemplate(SubMatches.SubMatches(0), Teks, halaman, PageID)' Lakukan penggantian modul
Konten = Ganti(Konten, SubMatches.value, SubTeks, 1, -1, 1)
Berikutnya
DataBind = Konten
Kalau tidak
Ikatan Data=
Akhiri Jika
Tetapkan Kecocokan = Tidak Ada
Fungsi Akhir
' ***************************************
' Cocokkan contoh templat
' ***************************************
Templat Item Fungsi Pribadi (ByVal TextTag, Teks ByVal, halaman ByVal, PageID ByVal)
Redupkan Kecocokan, SubMatches, SubMatchText
Redupkan SecMatch, SecSubMatch
Redupkan saya, TempText
Redupkan TextLen, TextLeft, TextRight
Setel Kecocokan = GetMatch(TextTag, /<ItemTemplate/>([/s/S]+)/<//ItemTemplate/>)
Jika Cocok. Hitung > 0 Lalu
Untuk Setiap Sub Pertandingan Dalam Pertandingan
SubMatchText = SubMatches.SubMatches(0)
'----------------------------------------------
' Mulai perulangan bersarang
'----------------------------------------------
SubMatchText = GridView(SubMatchTeks)
'----------------------------------------------
' Akhir dari perulangan yang bersarang
'----------------------------------------------
Jika UBound(Teks, 1) = 0 Maka
Teks Temp=
Kalau tidak
Teks Temp=
'-------------------------------------------------
'Mulai paging
'-------------------------------------------------
Jika Len(halaman) > 0 Dan halaman > 0 Lalu
Jika Len(CurrentPage) = 0 Atau CurrentPage = 0 Maka CurrentPage = 1
TextLen = UBound(Teks, 2)
TextLeft = (Halaman Saat Ini - 1) * halaman
TextRight = Halaman Saat Ini * halaman - 1
Jika TextLeft < 0 Maka TextLeft = 0
Jika TextRight > TextLen Maka TextRight = TextLen
c_PageStr = MultiPage(TextLen + 1, halaman, CurrentPage, PageUrl, float:right, , False)
Jika Int(Len(c_PageStr)) > 0 Maka
GantiPageStr = Array(<halaman: & Potong(IDPage) & />, c_PageStr)
Kalau tidak
GantiPageStr = Array(<halaman: & Potong(IDHalaman) & />, )
Akhiri Jika
Kalau tidak
TeksKiri = 0
TextRight = UBound(Teks, 2)
Akhiri Jika
Untuk i = TeksKiri Ke Kanan Teks
TempText = TempText & ItemReSec(i, SubMatchText, Text) 'Muat konten template
Berikutnya
Akhiri Jika
Berikutnya
Templat Item = Teks Temp
Kalau tidak
Templat Barang =
Akhiri Jika
Tetapkan Kecocokan = Tidak Ada
Fungsi Akhir
' ***************************************
'Ganti string templat
' ***************************************
Fungsi Pribadi ItemReSec(ByVal i, Teks ByVal, Array ByVal)
Pertandingan Redup, Sub Pertandingan
Setel Kecocokan = GetMatch(Teks, /$(/d+?))
Jika Cocok. Hitung > 0 Lalu
Untuk Setiap Sub Pertandingan Dalam Pertandingan
Teks = Ganti(Teks, SubMatches.value, doQuote(Arrays(SubMatches.SubMatches(0), i)), 1, -1, 1) 'Lakukan penggantian
Berikutnya
ItemReSec = Teks
Kalau tidak
ItemReSec=
Akhiri Jika
Tetapkan Kecocokan = Tidak Ada
Fungsi Akhir
' ***************************************
'Fungsi variabel global
' ***************************************
Sub Fungsi Eksekusi Pribadi
Redupkan Kecocokan, SubMatches, Teks, ExeText
Setel Kecocokan = GetMatch(c_Content, /<function/:([0-9a-zA-Z_/.]*?)/((.*?)/(.+?)/(.*?)/)// />)
Jika Cocok. Hitung > 0 Lalu
Untuk Setiap Sub Pertandingan Dalam Pertandingan
Teks = SubMatches.SubMatches(0) & ( & SubMatches.SubMatches(1) & & SubMatches.SubMatches(2) & & SubMatches.SubMatches(3) & )
Jalankan ExeText= & Teks
c_Content = Ganti(c_Content, SubMatches.value, ExeText, 1, -1, 1)
Berikutnya
Akhiri Jika
Tetapkan Kecocokan = Tidak Ada
Akhiri Sub
' ***************************************
' Penggantian label global yang biasa
' ***************************************
Let Set Properti Publik (ByVal t, ByVal s)
Redupkan SetMatch, Bstr, SetSubMatch
Setel SetMatch = GetMatch(c_Content, (/<Set/:([0-9a-zA-Z_/.]*?)/(((.*?) & t & (.*?))?/)// />))
Jika SetMatch.Count > 0 Lalu
Untuk Setiap SetSubMatch Di SetMatch
Jalankan Bstr = & SetSubMatch.SubMatches(1) & ( & SetSubMatch.SubMatches(3) & & s & & SetSubMatch.SubMatches(4) & )
c_Content = Ganti(c_Content, SetSubMatch.Value, Bstr, 1, -1, 1)
Berikutnya
Akhiri Jika
Setel SetMatch = Tidak Ada
Setel SetMatch = GetMatch(c_Content, (/<Set/: & t & ///>))
Jika SetMatch.Count > 0 Lalu
Untuk Setiap SetSubMatch Di SetMatch
c_Content = Ganti(c_Content, SetSubMatch.Value, s, 1, -1, 1)
Berikutnya
Akhiri Jika
Setel SetMatch = Tidak Ada
Properti Akhir
Kelas Akhir