asp 代码和模板分离方法?

BLAYD 2008-06-19 05:46:50
asp 代码和模板分离方法?
谁有asp 代码和模板的类啊?
...全文
293 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
BLAYD 2008-06-23
  • 打赏
  • 举报
回复
怎么没有人回答我的问题呢?大家帮帮忙啊!
BLAYD 2008-06-23
  • 打赏
  • 举报
回复
谢谢wtogether 的回答,谁能发个类上来啊?
tantaiyizu 2008-06-23
  • 打赏
  • 举报
回复
呵呵 ,看看这个 ,就是模板和逻辑代码分开的 ,你可以参考:
http://www.scriptlover.com/

redcn2004 2008-06-23
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 wtogether 的回复:]
模版统一保存到template目录下,而asp和html的文件名一一对应,例如:
index.asp对应template/index.html
reg.asp对应template/reg.html

下来看看如何使用template/index.html模版,假设index.html的内容为:
<html>
<head>
<title>$title </title>
</head>
<body>
$(Test, 1, 2)
</body>
</html>

然后在asp页面中,获取相应的模版,例如在index.asp中
<!--#include file="conn.asp"-->
<%
Di…
[/Quote]

此楼所说的正解
wtogether 2008-06-23
  • 打赏
  • 举报
回复
基本原理就是如此了,如何优化、如何设计自己喜欢的标签及如何做成ASP通用类,就看个人的修行了,这个类我是有,不过是公司的代码,不方便公开
wtogether 2008-06-23
  • 打赏
  • 举报
回复
模版统一保存到template目录下,而asp和html的文件名一一对应,例如:
index.asp对应template/index.html
reg.asp对应template/reg.html

下来看看如何使用template/index.html模版,假设index.html的内容为:
<html>
<head>
<title>$title</title>
</head>
<body>
$(Test, 1, 2)
</body>
</html>

然后在asp页面中,获取相应的模版,例如在index.asp中
<!--#include file="conn.asp"-->
<%
Dim strData, reg, arr, ptr
strData = [获取template/index.html的文本内容]
'处理$***变量标签
strData = Replace(strData, "$title", "标题")

'处理$(***, ***, ...)格式的函数标签
Set reg = New RegExp
reg.Global = True
reg.Pattern = "\$\(([^\)]+)\)"
Set arr = reg.Execute(strData)
For Each ptr In arr
strData = Replace(strData, ptr.Value, ASPCommand(ptr.SubMatches(0)))
Next
Set arr = Nothing
Set reg = Nothing

'输出解析后的模版
Response.Write strData

'将$(***, ***, ...)函数标签的$()包含的内容用Execute执行
Function ASPCommand(ByVal strData)
Dim arr1, arr2
Dim i
arr1 = Split(strData, ", ")
ReDim arr2(UBound(arr1) - 1)
For i = 1 To UBound(arr1)
arr2(i - 1) = "arr1(" & i & ")"
Next
'这里输出函数作调试用
'Response.Write "ASPCommand = " & arr1(0) & "(" & Join(arr2, ", ") & ")"
'这里执行函数
Execute "ASPCommand = " & arr1(0) & "(" & Join(arr2, ",") & ")"
End Function

'这个对应模版中的$(Test, 1, 2)函数标签
Function Test(a, b)
Test = a & " + " & b & " = " & (CInt(a) + CInt(b))
End Function
%>
BLAYD 2008-06-23
  • 打赏
  • 举报
回复
还是没有人回答啊?再等等吧!!
bhtfg538 2008-06-20
  • 打赏
  • 举报
回复
动网 用的组件 吧代码封装起来了
用 vb 开发工具 在 里面嵌入
在实例的 时候就
set a=createobject("")
BLAYD 2008-06-20
  • 打赏
  • 举报
回复
还有没有其他的方法 啊? 动网用的是什么方法啊?我看了一下他好像是用XSLT
Mapleleaf123 2008-06-20
  • 打赏
  • 举报
回复
replace(template,"$replacecode",docode)

就是replace多点啦
BLAYD 2008-06-20
  • 打赏
  • 举报
回复
就是ASP网站开发中,代码和模块分离怎么做?
BLAYD 2008-06-20
  • 打赏
  • 举报
回复
好像不是用的组件吧。
Linzhe423 2008-06-19
  • 打赏
  • 举报
回复
你要的是什么,不明白
BLAYD 2008-06-19
  • 打赏
  • 举报
回复
怎么没有人回答啊?自己先顶一下先

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧