Dynamator Pure HTML for every page generation technology.

Arbitrary Text

In the Hello World example, the text replaced was associated with an HTML element; specifically, the <p> element. It didn't have to be the <p> element; it could have been any element. But what if the text that needs to be replaced is not delimited by an HTML element?

The bad news is that Dynamator requires an HTML element. It can't locate arbitrary text. The good news is that there is an HTML 4.0 element created specifically for this purpose: <span>. The <span> element can be used to wrap arbitrary text. According to the HTML spec, <span> has no effect on the rendered browser output.

The Page

This example extends the original Hello World example slightly.


Once marked up with a <span> element, the file looks like this:

ArbitraryText.html (updated)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Hello World</title>
<p>The greeting for today is <span id="DynamicText">Hello world</span>

Other Files

Because this file uses the same ID value as the original HelloWorld example, and the behavior is the same, we could use the same Dynamator file. But because Dynamator expects the Dynamator file to have the same base name as the HTML file, we need to create a file with the name 'ArbitraryText.dyn'. This file could use the directive '<include file="HelloWorld.dyn"/> to reuse the original content.

Running dynamate

As in the first example, the HTML file needs to be processed by dynamate:

prompt=> java dynamate ArbitraryText.html

Generated JSP file

The above command produces the following file. Changes to the original HTML are highlighted.


In Action

If you are viewing this page in a servlet engine, you can see the generated page in action.


Because they provide a structured way to address arbitrary portions of an HTML document, the <span> and <div< elements are essential to site building with Dynamator.

This lesson only hints at an extremely powerful capability of Dynamator. Dynamator's loose coupling to HTML and it's <include> mechanism, combined with a strong naming convention, can enable a tremendous degree of reuse.