Title : suPerlative: The ht Preprocessor Author : ALR Abstract: ht is a pre-processor for HTML. It facilitates the maintenance of a large site by abstracting out common 'boilerplate' segments of code, e.g. header and footer segments that are similar system-wide. A number of varying styles and macros can also be supported. +++ Content : Central to our operations is 'ht', which takes a simplified HTML file and adds 'boilerplate' stuff such as banner ads and navigation menus. ht files start with a header such as:- Title : suPerlative: The ht Preprocessor Author : ALR Abstract: <b>ht</b> is a <em>pre-processor</em> for HTML. It facilitates the maintenance of a large site by abstracting out common 'boilerplate' segments of code, e.g. header and footer segments that are similar system-wide. A number of varying styles and macros can also be supported. +++ Content : Central to our operations is 'ht', which takes a simplified HTML file and adds 'boilerplate' stuff such as banner ads and navigation menus. ht files start with a header <a href="HT.ht">such as</a>:- It's wired with several standard conventions, such as author abbreviations ('AR' for 'Alan Richmond') and table macros, and with styles. There is a main program and several subroutines, e.g. Head and Foot, which are also used by most of our other scripts.

The benefits of using ht are:-

I believe most people think you only have two choices for creating HTML - use an editor or code by hand. But there's a third one which works very well for us: we use a (home-grown) preprocessor. If you like it's a variant of the template method; we have a number of styles built in and can modify them with some parameters. ht is a Perl preprocessor that I wrote for maintaining The WDVL. It allows me to write HTML without having to put on all the 'boilerplate'.

ht generates all the header, table and footer HTML... Using a preprocessor such as ht provides much more flexibility than typical HTML editors (which anyway tend to generate bloated and unreadable code) - for example I can easily change the site style by changing ht and running source files through it.. (very powerful when combined with style sheets).

An ht file looks like this.

You run the file through 'ht' and it sticks on the boilerplate, modified if necessary according to the header parameters and with any macros (abbreviations) expanded. This makes it very easy to create HTML in one of our standard styles, but you can also control the end result as much as you want since the input can contain HTML. And it's also very useful for our mirrors, e.g. there can be small differences automatically introduced such as crediting the host or pointing to CGI programs on the primary site because we don't have CGI access on every mirror. With 1,500 pages to maintain this would hard to do with an editor..

We don't currently use a database but a logical extension of this method would be to put the ht files into a database and then we could generate the pages dynamically, e.g. to account for browser differences. This approach isn't for everyone but anyone who wallows in Perl and HTML should love it..

Finally - ht also allows a small set of abbreviations; e.g.

<center> @Prev(Why.html) @Up(index.html) @Next(Stats.html) </center> creates the following links:-

@Prev(Why.html) @Up(index.html) @Next(Stats.html)

To use ht, you need:

You would certainly need to edit the subroutines file to change or remove things like the list of author initials, and the navigation menus.