As far as MarkupCentric approaches go, a template with embedded code is probably the simplest model to understand. Using this strategy, a special syntax is introduced with which programming language code can be embedded in an otherwise normal HTML document (or another markup language). Early FrameworkJSP is an example:

   1   <body>
   2     <% String[] words = {"these", "are", "words"};
   3        for (int i = 0; i < words.length(); i+=1) {
   4     %>
   5     <p>Word: <% words[i] %></p>
   6     <% } %>
   7   </body}>

Here, the brackets "<%" and "%>" are used to delimit Java code. Note that logically, line 5 is in the body of the for loop started in line 3. The semantics is that a copy of line 5 would be included in the output for each iteration of the for loop, yielding:

   1 <body>
   2   <p>Word: these</p>
   3   <p>Word: are</p>
   4   <p>Word: words</p>
   5 </body>

Some of these template languages employ the same semantics, but use their own, more lightweight syntax. Here is an example of Cheetah:

   1 <body>
   2 #for $word in $wordList
   3   <p>Word: $word</p>
   4 #end for
   5 </body>

EmbeddedCode (last edited 2006-01-26 14:25:27 by IwanVosloo)