2002/06.10 @09:37 (articles, blog, mod_include)

mod_include

What does this mod_include offer ?

Post-processing of variables contained within a variable.

Doesn’t sound too helpful ? Well, maybe not, but I found that during construction of this site that I was frequently replicating 5 lines of text with only a single word altered (the left menu). This was both inefficient and awkward to debug, and didn’t lend itself to keeping a common look and feel for the site as a whole. This extension allows large blocks of text to be stored as a variable, and for the small changable part to be altered just before the result is displayed.

What’s wrong with set anyway ?

When a variable is used in the value entry of a set command the system searches for the current value of the variable and substitutes it immediately. This fixes the value of the variable created so that it never changes, which is good for some applications, but lousy for dynamic content.

Usage

This module is an extension of the normal Apache behaviour, and should be read as an addendum to the basic mod_include commands.

I do have more than just mod_include compiled into Apache, but the difference between the basic version and mine is 5136 bytes in the httpd executable. I don’t think that the time for standard mod_include calls would be adversely effected, as there are only two extra tests for the new words, and performance of those words is not comparable to the old system.

Licen[c|s]e

I’m not interested in making things any more difficult than they already are in this area, so this patch is distributed under the Apache Licence.

Download

Choose from a diff for Apache 1.3.24/1.3.26, or simply grab the entire mod_include.c file. For the merely curious, there is also an online version.

Improvements

The element order checking is not robust for #macro.

Feedback / Bugs / Feature Requests

Just send it to me and I’ll see what I can do to help out. Bear in mind that I’m doing this primarily for myself, so porting to various other versions of Apache is only likely to happen when I need it, but I’m more than happy to help out if required.