Normally, an application will have one or more PageProducers -
components that generate html. The normal approach is to create
an html template per PageProducer
and place them in either HTMLDoc or HTMLFile.
(I prefer HTMLDoc because everything is compiled into a single file.
HTMLFile allows modifying the templates without recompiling the application.)
These templates are basically just regular html with a few special tags -
the OnHTMLTag event allows your program to replace the tags
with the appropriate html.
Each web server should have a single OnHTMLTag method and
that method should be assigned to the OnHTMLTag
event of all the PageProducers
This method will be called once for each tag in the template
All PageProducers will interpret the tags the same way
It allows one template to include another
In the Delphi 5 help,
The tag format is defined under
In the generic case, a query is sent to the datamodule before html_Format_List is called.
In other cases, I have predefined queries. In the example above,
setting Group_ID controls which records are returned.
In some applications, the header and footer information are basically
the same for several pages.
I have defined header and footer templates in
if CompareText(TagString, 'Common_Header') = 0 then begin
ReplaceText := PageProducer_Common_Header.Content ;
if CompareText(TagString, 'Common_Footer') = 0 then begin
ReplaceText := PageProducer_Common_Footer.Content ;
This is quite involved, it contains the html, head, and body tags
In the case of my portable barcode reader, this also contains
Form start and end tags
Hidden field tags, to keep the same data available on all related pages