国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南召县| 榆中县| 滨州市| 祁阳县| 永德县| 玛多县| 谢通门县| 大理市| 西宁市| 集安市| 普宁市| 伊川县| 南丹县| 霞浦县| 商河县| 孟连| 佛坪县| 来宾市| 女性| 依安县| 朔州市| 汤阴县| 石渠县| 象州县| 盖州市| 克山县| 如皋市| 台北县| 石屏县| 长白| 旬阳县| 壤塘县| 十堰市| 新泰市| 松原市| 阳西县| 中阳县| 金湖县| 溧阳市| 余干县| 华阴市|