Tmplz Template API

Tmplz Tags

Core Tags: Section

Section tags demarcate a block of content that is invisible by default; it must be explicitly "shown" (via the Show tag or Section.show() Java method), and appends copies to itself when shown multiple times. A Section always has a name, and always requires both a starting tag and an ending tag. A simple example:

    [$Section MySection] Hello World. [$Section]

Allowable sub-tags

A template is essentially an "unnamed" Section, so a Section can contain any template tag. Additionally, a Section can contain Between tags (described in a later chapter), which are not used outside of Sections.

Shown below are helpful examples of nested Slots and Sections:

Nested Slots

  <table>
    [$Section Row]
      <tr>
        <td>[$Slot FirstName]</td><td>[$Slot LastName]</td>
      </tr>
    [$Section]
  </table>  

Here a Section named "Row" is defined, containing two Slots; every time the Section is shown, those Slots can be filled in with different values. Thus we can use this template to create an HTML table with multiple rows of varying data.

Nested Sections

  <table>
    [$Section Row]
      <tr>
        [$Section Column]
          <td>[$Slot Value]</td>     
        [$Section]
      </tr>
    [$Section]
  </table>  

Here the "Row" Section contains the "Column" Section, which in turn contains a Slot named "Value". This example template could be used to create an HTML table with any number of rows, each containing any number of columns, and each column containing a different value.

Using the Same Section Name More Than Once

If multiple Sections have the same name, they will be treated as a single Section and all will be shown when the Template is instructed to show them. It is okay, however, if Sections with the same name have differently named sub-Sections and Slots.

Next page: Include Tags