国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

關于通過vbs類處理模板實現代碼與界面分離的程序,建議入精華備查。有演示

2024-07-21 02:15:35
字體:
來源:轉載
供稿:網友
文章標題:vbs類處理模板實現代碼與界面分離
'作者:yanek
'email:[email protected]

本程序通過vbs類處理模板實現代碼與界面分離的程序,主要有下面文件組成
index.asp,parse_cls.asp,template.html
下面是代碼

1。index.asp 調用vbs類處理模板

<%
'作者:yanek
'email:[email protected]

'---  ---
' index.asp
'------  ----
' (c)2000 james q. stansfield ([email protected])
' this code is free for use by anyone. it is meant as a learning tool and can be passed along in any format.
option explicit
%>
<!--#include file="parse_cls.asp"-->
<%
'declare our variables
dim g_opagegen
'cerate the class object
set g_opagegen = new parsetmpl
'set the template file
g_opagegen.templatefile = "template.html"
'add some custom tags to the dictionary
g_opagegen.addtoken "title", "template example"
g_opagegen.addtoken "copyright", "this is mine! all mine!"
g_opagegen.addtoken "quote", """tell jabba i've got his money!""<br>--han solo, star wars 1977"
g_opagegen.addtoken "menu", "home page<br>news page<br>link page"
g_opagegen.addtoken "content", "welcome to my home page... yadda yadda yadda!"
'generate the page
g_opagegen.generatehtml
'destroy our objects
set g_opagegen = nothing
%>



2。parse_cls.asp  處理模板類文件

<%
'作者:yanek
'email:[email protected]

'---  ---
' parse_cls.asp
' this code is free for use by anyone. it is meant as a learning tool and can be passed along in any format.
class parsetmpl
    'dimension variables
    private g_stmplfile
    private g_odict
    private g_bfile

    private sub class_initialize
        'create the scripting.dictionary object,
        'set the compare mode to 1 so that it is case insensitive.
        'also flag a boolean file so we know whether our file is there or not.
        set g_odict = createobject("scripting.dictionary")
        g_odict.comparemode = 1
        g_bfile = false
    end sub
    
    private sub class_terminate
        'destroy our object.
        set g_odict = nothing
    end sub
    
    public property let templatefile(infile)
        'a file & path must be specified for the routine to work.
        g_stmplfile = server.mappath(infile)
    end property
    
    private property get templatefile()
        templatefile = g_stmplfile
    end property
    
    public sub addtoken(intoken, invalue)
        'this property allows us to set our tokens.
        g_odict.add intoken, invalue
    end sub
    
    public sub generatehtml
        'this is the main, and only public method of the class.
        'this method will check whether we've specified a file or not.
        'check for the files existance if we have specified it.
        'if the file exists we will open it and dumps it's contents into an array.
        'the array is split on vbcrlf to make it more manageable.
        if len(g_stmplfile) > 0 then
            dim l_ofso, l_ofile, l_arrfile
            set l_ofso = createobject("scriptin

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凌源市| 河北区| 南昌县| 永善县| 揭阳市| 三江| 通道| 上杭县| 宁强县| 平乡县| 成安县| 沭阳县| 东山县| 渑池县| 潢川县| 胶州市| 平遥县| 廉江市| 鄂尔多斯市| 三原县| 县级市| 鹿泉市| 达日县| 隆回县| 宁夏| 兴山县| 田林县| 平遥县| 苍南县| 桓台县| 舒城县| 永安市| 关岭| 南安市| 土默特左旗| 海淀区| 锡林浩特市| 六安市| 云安县| 栾川县| 黑龙江省|