Simple ASP Template 1.5 Demo

This very simple demo illustrates how to use the ASP Template class to separate code and content. The template file is striaghtforward:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>[%title%]</title>
</head>

<body>
[%date%]<br>
<hr>
This is me after losing a bet...<br>
<a href="http://senators.iridani.net"><img src="[%images%]jqs.jpg" border="0"></a>
</body>
</html>

The token date is replaced by formatdatetime(now(), 3); the token title is replaced by ASP Templates [1.5] Simple; and, finally, the template images is replaced by /demos/asptemplates/templates/Simple/images/. The output can be seen below.


ASP Templates [1.5] Simple 4:03:49 PM


This is me after losing a bet...


Source Code

<!--#INCLUDE file="includes/template_cls.asp"-->
<%
'Simple1.asp
dim objTemplate
const TMPLDIR = "/demos/asptemplates/templates/Simple/tmpl/"
const IMGDIR = "/demos/asptemplates/templates/Simple/images/"
set objTemplate = new template_cls
with objTemplate
	.TemplateFile = TMPLDIR & "template.html"
	.AddToken "date", STRINGVARIABLE, formatdatetime(now(), 3)
	.AddToken "title", STRINGVARIABLE, "ASP Templates [1.5] Simple"
	.AddToken "images", STRINGVARIABLE, IMGDIR
	.parseTemplateFile
end with
set objTemplate = nothing
%>


[View the complex.asp demo] | [View the ReallyComplex.asp demo] | [Return to the article]