Really Complex ASP Template 1.5 Demo

This really complex demo illustrates a more practical application of the ASP Template class. You can create rich templates with various HTML and backgrounds and then plug in the text to whatever HTML "shell" you want.


Default Template

Select A Template To Use :

This page is being rendered using version 1.5 of the ASP Template class.

In this demo you can quickly switch between several different templates created from current websites. (Sorry, didn't want to steal too many of them, this was just for educational purposes.)



Source Code

<!--#INCLUDE FILE="includes/template_cls.asp"-->
<!--#INCLUDE FILE="includes/functions.asp"-->
<%
response.expires = -1
dim intID
intID = getID()
call doTemplate(intID)

function getID
	dim intValue
	getID = 0
	intValue = request.querystring("ID")
	if isnumeric(intValue) then
		if not(isempty(intValue)) then
			getID = intValue
		end if
	end if
end function
sub doTemplate(inID)
	dim objTemplate, strPath
	set objTemplate = new template_cls
	with objTemplate
		select case intID
			case 0
				strPath = "/demos/asptemplates/templates/default/tmpl/"
				.TemplateFile = strPath & "main.html"
				.AddToken "imgpath", STRINGVARIABLE, "/demos/asptemplates/templates/default/images/"
				.AddToken "content", INCLUDEANDNOPARSE, "/demos/asptemplates/content/main.html"
				.AddToken "source", STRINGVARIABLE, strip(.loadFile("/reallycomplex.asp", 1))
			case 1
				strPath = "/demos/asptemplates/templates/4guys/tmpl/"
				
				.AddToken "imgpath", STRINGVARIABLE, "/demos/asptemplates/templates/4guys/images/"
				.AddToken "4guys.style", INCLUDEANDPARSE, strPath & "style.html"
				.AddToken "4guys.header", INCLUDEANDPARSE, strPath & "header.html"
				.AddToken "OAS.JS", INCLUDEANDNOPARSE, strPath & "OAS-JS.html"
				.AddToken "OAS.486X60_1", INCLUDEANDPARSE, strPath & "OAS486X60-1.html"
				.AddToken "OAS.486X60_2", INCLUDEANDPARSE, strPath & "OAS486X60-2.html"
				.AddToken "4guys.left", INCLUDEANDPARSE, strPath & "left.html"
				.AddToken "4guys.center", INCLUDEANDPARSE, strPath & "center.html"
				.AddToken "4guys.right", INCLUDEANDPARSE, strPath & "right.html"
				.AddToken "4guys.footer", INCLUDEANDPARSE, strPath & "footer.html"
				.AddToken "content", STRINGVARIABLE, FourGuysBox(.loadFile("/demos/asptemplates/content/main.html", 1), "ASP Template v1.5")
				.AddToken "source", STRINGVARIABLE, FourGuysBox(strip(.loadFile("/demos/asptemplates/reallycomplex.asp", 1)), "Source Code")
				.TemplateFile = strPath & "template.html"
		end select
		.AddToken "SELECT" & intID, STRINGVARIABLE, " SELECTED"
		.AddToken "tmplMenu", INCLUDEANDPARSE, "/demos/asptemplates/includes/tmpl/form.html"
	response.write(.getParsedTemplateFile)
	end with
	set objTemplate = nothing
end sub
function strip(inItem)
	inItem = replace(inItem, "<", "<")
	inItem = replace(inItem, ">", ">")
	inItem = replace(inItem, vbTab, "    ")
	inItem = replace(inItem, VbCrLf, "<br>")
	strip = inItem
end function
function FourGuysBox(inContent, inTitle)
	dim objTemplate
	set objTemplate = new template_cls
	with objTemplate
		.AddToken "content", STRINGVARIABLE, inContent
		.AddToken "title", STRINGVARIABLE, inTitle
		.AddToken "date", STRINGVARIABLE, formatdatetime(now, 4)
		.TemplateFile = "/demos/asptemplates/templates/4guys/tmpl/Box.html"
		FourGuysBox = .getParsedTemplateFile
	end with
	set objTemplate = nothing
end function
%>


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