HTML Redemption Language

HTML Redemption Language, or HRL for short, is an HTML-preprocessor. It's basically a macro package, with built-in Python scripting. It redeems HTML by adding useful tags such as <include>, <macro>, <if>, and <python>. The last tag allows the web site designer to embed Python "scriptlets" in the HRL source to perform complex preprocessing tasks.

HRL is a preprocessor, designed to be invoked manually by the user to generate the web site. It is not fast enough to generate web pages on the fly. A comparable package is hsc.


Documentation

The file doc/manual.html in the distribution contains the documentation for HRL.

Here is a very simple example of what HRL can do. In document.hri:

    <macro name="document" req="title" container>
      <html>
        <head>
          <title><e val="((title))"></title>
        </head>
        <body bgcolor="#FFFFFF" text="#000000">
          <h1><e val="((title))"></h1>
          <content>
        </body>
      </html>
    </macro>
In index.hrl:
    <include file="document.hri">
    <document title="My Home Page">
      Hi! this is my web page! <p>
      <python>
        from time import time, ctime
        hrl.doc.write ('Page last generated on ' + ctime(time()) 
                       + '.<br>')
      </python>
    </document>

What happens here is the file document.hri defines a macro, <document>, that encapsulates the whole web page. The file index.hrl includes document.hri, then uses the <document> macro in lieu of <html><head><body>. In the output, the content of the <document> tag gets inserted into the macro definition where the <content> tag appears. Any other file could also include document.hri and use the <document> macro. This makes it easy to maintain a consistent style across many web pages.

Also, note the Python script that prints out the time the page was generated.

Yet HRL is far more powerful than this simple example demonstrates. For instance, you can do things such as nesting <python> tags inside of <macro> definitions, allowing you to write very powerful macros, and add hooks that can change and modify regular HTML tags. In addition, HRL has useful features such as decimating whitespace and replacing entities. See doc/manual.html for more details.

Almost all web pages on my site were generated using HRL, using these very advanced features.


Downloads

HRL is licensed under a BSD-style license. The current version is 0.5, released May 11, 2006.

Version 0.5:


Links

There are two web sites I know of that use or once used HRL:

  • Aoidoi.org - An interesting site dedicated to Ancient Greek poetry.
  • manicai.net - Some guy that once used it to maintain a wine database.

HTML generators seem to be something we are very picky about. There are millions of them, yet many people (including myself) are willing to write their own when no other package offers the right combination of features or ease-of-use.

There are no shortage of HTML/web servers/generators/frameworks out there. Here is a very spiffy list of them.


Feedback

Comments, questions?

My current address is hrl-23@aerojockey.com.


Copyright (c) 2001-2008 Carl Banks. All Rights Reserved.