注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

古城风~~~

竹密无妨溪水过,天高不碍白云飞。这天下总有一份是属于我古城的天地!

 
 
 

日志

 
 

ASP Template (ASP模板)  

2010-11-17 14:09:45|  分类: asp |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

ASP Template
http://sourceforge.net/projects/asptemplate/
ASP Template is an ASP/ASPX templating library aimed at separating code from HTML just like ITX and Smarty do for PHP.

 

'######################default.asp######################

 

<%@ Language=VBScript %>
<%
'    ASP Template Example Script 1
'    Copyright (C) 2001-2004 Valerio Santinelli
'
'    This library is free software; you can redistribute it and/or
'    modify it under the terms of the GNU Lesser General Public
'    License as published by the Free Software Foundation; either
'    version 2.1 of the License, or (at your option) any later version.
'
'    This library is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
'    Lesser General Public License for more details.
'
'    You should have received a copy of the GNU Lesser General Public
'    License along with this library; if not, write to the Free Software
'    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'
'   ---------------------------------------------------------------------------
'
' Main Example File
'
' Author: Valerio Santinelli <tanis@altralogica.it>
' $Id: default.asp 48 2004-09-02 20:55:01Z tanis $
'
%>
<!--#INCLUDE FILE="..\asptemplate.asp"-->
<%
'Declare our template variable
dim t

'Create the class object
set t = New ASPTemplate

'Set the main template file
t.SetTemplateFile "layout.html"

'Add some custom tags to the template
t.SetVariable "title", "ASP Template Example Script 1"

'We add some more text to this tag
t.Append "title", " - Main Page"

'Load an external file into a tag.
t.SetVariableFile "content", "content.html"

'Load another external file that will be used to draw some blocks
t.SetVariableFile "menu", "menu.html"

'Setup the block
t.UpdateBlock "menu_block"

'Set and parse the block
t.SetVariable "menu_text", "HOME"
t.ParseBlock "menu_block"

'Do it multiple times
t.SetVariable "menu_text", "NEWS"
t.ParseBlock "menu_block"

t.SetVariable "menu_text", "CREDITS"
t.ParseBlock "menu_block"

 

'Store the blocks in their directory service (order is important)

t.UpdateBlock "c_block"
t.UpdateBlock "b_block"
t.UpdateBlock "a_block"


t.SetVariable "inner", "666666"
t.SetVariable "outer", "Outer Block (A)"

t.SetVariable "whatever", "Block C 1"
t.ParseBlock "c_block"
t.SetVariable "whatever", "Block C 2"
t.ParseBlock "c_block"
t.SetVariable "whatever", "Block C 3"
t.ParseBlock "c_block"

t.SetVariable "into_b", "Block B 1"
t.ParseBlock "b_block"

t.SetVariable "whatever", "Block C 1(b)"
t.ParseBlock "c_block"
t.SetVariable "whatever", "Block C 2(b)"
t.ParseBlock "c_block"

t.SetVariable "inner", "999999"

t.SetVariable "into_b", "Block B 2"
t.ParseBlock "b_block"

t.ParseBlock "a_block"


'Generate the page
t.Parse

'Destroy our objects
set t = nothing
%>

 

 

模板文件共三个,这里只发出来一个。
content.html
layout.html
menu.html


'#######################layout.html##################

 

<html>
<head>
<title>{{title}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#333333" text="#FF6633" link="#FF3333" vlink="#660000" alink="#FF0000">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td colspan="2">
      <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="4">{{title}}</font></b></font></div>
    </td>
  </tr>
  <tr>
    <td width="22%">{{menu}} </td>
    <td width="78%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">You
      should see some content down here <br>
      {{content}} </font></td>
  </tr>
</table>
<!-- BEGIN a_block -->
<table width="100%" border="0" cellspacing="2" cellpadding="2" bgcolor="#003333">
  <tr>
    <td>
      <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="4">{{outer}}</font></b></font>
      <!-- BEGIN b_block -->
        <table width="90%" border="0" cellspacing="2" cellpadding="2" bgcolor="{{inner}}">
          <tr>
            <td bgcolor="#003366" align="center">
              {{into_b}}
              <!-- BEGIN c_block -->
              <table width="90%" border="0" cellspacing="2" cellpadding="2" bgcolor="{{inner}}">
          <tr>
            <td bgcolor="#003366">
              <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="4">{{whatever}}</font></b></font>
              </div>
          </td>
        </tr>
      </table>
              <!-- END c_block -->
            </td>
        </tr>
      </table>
      <!-- END b_block -->
      </div>
    </td>
  </tr>
</table>
<!-- END a_block -->
</body>
</html>

 

本文来源于网络

  评论这张
 
阅读(504)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017