See also the new age of the HTML templates in ASP. See the ALP Catalog Type 2. A combination of an ActiveX and ASP code provides something better than JSP and ASP.NET can possibly offer.
This sample code realizes simple but useful HTML template functionality. With this
component you can create different looking ASP code or applications written using other
technique (such us C++) and give them ability to generate HTML pages over a predefined
template. Using HTMLTemplate you can fully separate HTML from executable code. This
technique gives you ability to create exportable pages, thus implementing critical
dynamicaly generated pages as exporters of plain HTML you can create faster sites on slow
server. In addition you can implement page generation not in ASP (running on WEB requests)
but as scripts for Windows Scripting Host for example. In this case you can schedule page
site regeneration for certain hours and so on ...
ZmeY soft provides this code as example of using Windows scripting technologies, You
can use it for any purpose without need of additional permissions from us. You can modify
code to meet your needs, add features, use code in your own applications (commercial too).
Code is provided AS IS without any warranty.
Temlate consist of parts - only one Global area
and any number of detail parts.
- Global part is any text that does not belong to a detail
- Detail part is part of the template that begins with <%DETAIL_NAME%> and ends with <%DETAIL_NAME%> tags. DETAIL_NAME can be any alpha-numeric
combination. Details can NOT be nested or crosslinked.
Every part can contain any number of replaceable tags. Replaceable tag
is name enclosed in "~" symbols - example: ~TAG_NAME~.
Tag name can be any alphanumeric combination.
Details can not begin or and at the beginning or end of the template. At least one
symbol must exist before first and after last detail tag. For HTML it is not a problem but
if you want to change code it is recommended to choose some easy solution like adding
spaces on initialization and removing them when getting results. Thish will work faster
than algorythm changes that require more complex regular expressions and additional
How it works ?
HTMLTemplate object have a state property currentPart (see reference
below) that specifies currently active part of the template. Replaceable tags
are accessible only in the active/current part. Global part always appeares in the output,
detail parts will not appear in the output as long as AddNew() is not
used to add a copy. Thus setting currentPart to a detail name does nothing - you will need
to use method AddNew() to add copy of the detail and then you can replace
tags in this copy. You can repeat this action many times - thus any detail can be repeated
many times (useful for list of tabular data for example). To understand oblect
functionality in details see example code and example page (note that control must be
registerd in order to use example page).
Object is implemented using regular expressions.