HTML Redemption Language

  • Language: Python
  • License: BSD-style

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. HRL is based on an ancient package called 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.

Status

As of July 4, 2010, I’ve jumped on the dynamic web content bandwagon for my web sites. I no longer use HRL to generate my web sites, and so I’ve officially discontinued work on it.

For web templating, I now use Mako. Mako has all the features that I wanted when I first designed HRL, and is fast enough to be used for dynamic content. If Mako had been around ten years ago I probably wouldn’t have written HRL.

1 Comment

Add a Comment
  1. Today is october 30th, 2017 and i still use hrlc for generating my statics pages. I started using hrlc 10 years ago!
    A very big Thank to you!
    Best regards,
    DB

Leave a Reply

Your email address will not be published. Required fields are marked *

Frontier Theme