数码资讯
共享一个好东东,动态包含文件(动态文件包含)
早在03年前,我就看到了动态的文章包括蓝色的理想。当时我感觉很好,但实际使用起来并不方便,加起来的效果还不够好。 后来,我在一个网站上看到了一个改进的版本,但是使用它不是很好。 嗯,我真的想放弃ASP,但因为公司仍然使用ASP来开发它,我没有办法做到这一点。 今天,我要记住今天~在一个国外的网站上我
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
早在03年前,我就看到了动态的文章包括蓝色的理想。当时我感觉很好,但实际使用起来并不方便,加起来的效果还不够好。
后来,我在一个网站上看到了一个改进的版本,但是使用它不是很好。
嗯,我真的想放弃ASP,但因为公司仍然使用ASP来开发它,我没有办法做到这一点。
今天,我要记住今天~在一个国外的网站上我发现了这么好的东东,很棒的大工程!!!!
一些动态包含的代码以前尝试过不能包含一个类,甚至函数为~,或者包含在包含文件中不能包括在内…
Now the class that dselkirk writes can do for us.
复制代码代码如下所示:
<
公众包括include_vars
设置包括=新cls_include
类cls_include
私有子class_initialize()
集include_vars = server.createobject(脚本。词典)
端子
私有子class_deactivate()
arr_variables.removeall
集include_vars =没有
设置包含=无
端子
公共默认功能包括(ByVal str_path)
昏暗的str_source
如果str_path <>然后
str_source = ReadFile(str_path)
如果str_source <>然后
包括str_source
convert2code str_source
formatcode str_source
如果str_source <>然后
如果request.querystring(调试)= 1
response.write str_source
response.end
其他的
executeglobal str_source
include_vars.removeall
最后如果
最后如果
最后如果
最后如果
端功能
私有子convert2code(str_source)
朦胧的我,str_temp,arr_temp,int_len
如果str_source <>然后
如果仪器(str_source,% >>等)(str_source,< %)然后
str_temp =取代(str_source,<%
str_temp =取代(str_temp,% >
如果左(str_temp,1)=| 然后str_temp =右(str_temp,len(str_temp)- 1)
如果对(str_temp,1)=| 然后str_temp =左(str_temp,len(str_temp)- 1)
arr_temp =分裂(str_temp,| )
int_len = UBound(arr_temp)
如果(int_len + 1)> 0
我int_len = 0
str_temp =装饰(arr_temp(我))
str_temp =取代(str_temp,vbcrlf vbcrlf,vbcrlf)
如果左(str_temp,2)= vbcrlf然后str_temp =右(str_temp,len(str_temp)- 2)
如果对(str_temp,2)= vbcrlf然后str_temp =左(str_temp,len(str_temp)- 2)
如果左(str_temp,1)=%然后
str_temp =右(str_temp,len(str_temp)- 1)
如果左(str_temp,1)==然后
str_temp =右(str_temp,len(str_temp)- 1)
str_temp =响应。写str_temp
最后如果
其他的
如果str_temp <>然后
include_vars.add我,str_temp
str_temp =response.write include_vars.item(我)。
最后如果
最后如果
str_temp =取代(str_temp,CHR(34)CHR(34)
str_temp =取代(str_temp,CHR(34)CHR(34),)
如果对(str_temp,2)vbcrlf然后str_temp <> = str_temp
arr_temp(我)= str_temp
下一个
str_source =加入(arr_temp,vbcrlf)
最后如果
其他的
如果str_source <>然后
include_vars.add 功
str_source =response.write include_vars.item(功)。
最后如果
最后如果
最后如果
端子
Private Sub过程包括(str_source)
昏暗的int_start,str_path,str_mid,str_temp
str_source =取代(str_source <!——#
int_start =仪器(str_source,<!——#包括)
str_mid = 1例(getbetween(str_source,))
直到int_start = 0
str_mid = 1例(getbetween(str_source,))
int_start =仪器(str_mid,#包括)
如果int_start > 0
str_temp = 1例(getbetween(str_mid,CHR(34),CHR(34))))
str_temp =装饰(str_temp)
str_path = ReadFile(str_temp)
str_source =取代(str_source,
最后如果
int_start =仪器(str_source,#包括)
环
端子
私有子formatcode(str_code)
朦胧的我,arr_temp,int_len
str_code =取代(str_code,vbcrlf vbcrlf,vbcrlf)
如果左(str_code,2)= vbcrlf然后str_code =右(str_code,len(str_code)- 2)
str_code =装饰(str_code)
如果仪器(str_code,vbcrlf)> 0
arr_temp =分裂(str_code,vbcrlf)
我= 0,UBound(arr_temp)
arr_temp(我)= LTrim(arr_temp(我))
如果arr_temp(我)< >然后arr_temp(我)= arr_temp(我)vbcrlf
下一个
str_code =加入(arr_temp,)
arr_temp = vbnull
最后如果
端子
私有函数ReadFile(str_path)
昏暗的objfso,名字
如果str_path <>然后
如果仪器(str_path,)= 0然后str_path = server.mappath(str_path)
集objfso = server.createobject(脚本。FileSystemObject )
如果objfso.fileexists(str_path)然后
设置名字= objfso.opentextfile(str_path,1,假)
如果err.number = 0
objfile.readall ReadFile =
objfile.close
最后如果
设置名字=没有
最后如果
集objfso =没有
最后如果
端功能
私有函数getbetween(strdata,strstart,Strend)
昏暗的lngstart,lngend
lngstart =仪器(strdata,strstart)+ len(strstart)
如果(lngstart <> 0)
lngend =仪器(lngstart,strdata,Strend)
如果(lngend <> 0)
getbetween =中(strdata,lngstart,lngend - lngstart)
最后如果
最后如果
端功能
类的结束
%>
后来,我在一个网站上看到了一个改进的版本,但是使用它不是很好。
嗯,我真的想放弃ASP,但因为公司仍然使用ASP来开发它,我没有办法做到这一点。
今天,我要记住今天~在一个国外的网站上我发现了这么好的东东,很棒的大工程!!!!
一些动态包含的代码以前尝试过不能包含一个类,甚至函数为~,或者包含在包含文件中不能包括在内…
Now the class that dselkirk writes can do for us.
复制代码代码如下所示:
<
公众包括include_vars
设置包括=新cls_include
类cls_include
私有子class_initialize()
集include_vars = server.createobject(脚本。词典)
端子
私有子class_deactivate()
arr_variables.removeall
集include_vars =没有
设置包含=无
端子
公共默认功能包括(ByVal str_path)
昏暗的str_source
如果str_path <>然后
str_source = ReadFile(str_path)
如果str_source <>然后
包括str_source
convert2code str_source
formatcode str_source
如果str_source <>然后
如果request.querystring(调试)= 1
response.write str_source
response.end
其他的
executeglobal str_source
include_vars.removeall
最后如果
最后如果
最后如果
最后如果
端功能
私有子convert2code(str_source)
朦胧的我,str_temp,arr_temp,int_len
如果str_source <>然后
如果仪器(str_source,% >>等)(str_source,< %)然后
str_temp =取代(str_source,<%
str_temp =取代(str_temp,% >
如果左(str_temp,1)=| 然后str_temp =右(str_temp,len(str_temp)- 1)
如果对(str_temp,1)=| 然后str_temp =左(str_temp,len(str_temp)- 1)
arr_temp =分裂(str_temp,| )
int_len = UBound(arr_temp)
如果(int_len + 1)> 0
我int_len = 0
str_temp =装饰(arr_temp(我))
str_temp =取代(str_temp,vbcrlf vbcrlf,vbcrlf)
如果左(str_temp,2)= vbcrlf然后str_temp =右(str_temp,len(str_temp)- 2)
如果对(str_temp,2)= vbcrlf然后str_temp =左(str_temp,len(str_temp)- 2)
如果左(str_temp,1)=%然后
str_temp =右(str_temp,len(str_temp)- 1)
如果左(str_temp,1)==然后
str_temp =右(str_temp,len(str_temp)- 1)
str_temp =响应。写str_temp
最后如果
其他的
如果str_temp <>然后
include_vars.add我,str_temp
str_temp =response.write include_vars.item(我)。
最后如果
最后如果
str_temp =取代(str_temp,CHR(34)CHR(34)
str_temp =取代(str_temp,CHR(34)CHR(34),)
如果对(str_temp,2)vbcrlf然后str_temp <> = str_temp
arr_temp(我)= str_temp
下一个
str_source =加入(arr_temp,vbcrlf)
最后如果
其他的
如果str_source <>然后
include_vars.add 功
str_source =response.write include_vars.item(功)。
最后如果
最后如果
最后如果
端子
Private Sub过程包括(str_source)
昏暗的int_start,str_path,str_mid,str_temp
str_source =取代(str_source <!——#
int_start =仪器(str_source,<!——#包括)
str_mid = 1例(getbetween(str_source,))
直到int_start = 0
str_mid = 1例(getbetween(str_source,))
int_start =仪器(str_mid,#包括)
如果int_start > 0
str_temp = 1例(getbetween(str_mid,CHR(34),CHR(34))))
str_temp =装饰(str_temp)
str_path = ReadFile(str_temp)
str_source =取代(str_source,
最后如果
int_start =仪器(str_source,#包括)
环
端子
私有子formatcode(str_code)
朦胧的我,arr_temp,int_len
str_code =取代(str_code,vbcrlf vbcrlf,vbcrlf)
如果左(str_code,2)= vbcrlf然后str_code =右(str_code,len(str_code)- 2)
str_code =装饰(str_code)
如果仪器(str_code,vbcrlf)> 0
arr_temp =分裂(str_code,vbcrlf)
我= 0,UBound(arr_temp)
arr_temp(我)= LTrim(arr_temp(我))
如果arr_temp(我)< >然后arr_temp(我)= arr_temp(我)vbcrlf
下一个
str_code =加入(arr_temp,)
arr_temp = vbnull
最后如果
端子
私有函数ReadFile(str_path)
昏暗的objfso,名字
如果str_path <>然后
如果仪器(str_path,)= 0然后str_path = server.mappath(str_path)
集objfso = server.createobject(脚本。FileSystemObject )
如果objfso.fileexists(str_path)然后
设置名字= objfso.opentextfile(str_path,1,假)
如果err.number = 0
objfile.readall ReadFile =
objfile.close
最后如果
设置名字=没有
最后如果
集objfso =没有
最后如果
端功能
私有函数getbetween(strdata,strstart,Strend)
昏暗的lngstart,lngend
lngstart =仪器(strdata,strstart)+ len(strstart)
如果(lngstart <> 0)
lngend =仪器(lngstart,strdata,Strend)
如果(lngend <> 0)
getbetween =中(strdata,lngstart,lngend - lngstart)
最后如果
最后如果
端功能
类的结束
%>
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。