I'm looking for an HTML-compliant content management system that has a fairly flexible feature for customizing text for different web sites. Suggestions are invited!

Following is a rough description of what I have in mind. I can consider any design that lets me achieve essentially the same result, and produces web sites that are reasonably easy to build and maintain.

An HTML page may include special tags that represent preprocessing operations. The CMS performs the required operations before sending the HTML to the browser.

One tag might look like this:

<include pathname>

This means, "Replace this tag with the contents of pathname."

If the pathname is relative, the CMS searches for it in a hierarchy of directories defined when the site was configured.

The <include> tag is recursive. That is, a file that is included into a loaded file may contain another <include> tag which includes another file into itself, and so on, to any reasonable depth.

As an example of how the facility could be used: the directory hierarchy might look like this:

/client (substitution files for this particular web site)
/state (substitution files for the web site sponsor's state or province)
/country (substitution files for the web site sponsor's country)
/default (substitution files for cases not otherwise defined)

When the CMS encounters a tag like <include notices.inc> it searches for /client/notices.inc, /state/notices.inc, /country/notices.inc, or /default/notices.inc, and replaces the tag with the first one it finds. This could be used to insert boilerplate notices required by national or state/provincial law.

Another tag is:

<var varname>

This means, "Replace the tag with the value of the configuration variable varname." It could be used to replace text like "Welcome to the <var clientName> web site!" with "Welcome to the Edible Foods Corporation web site!"