Tmplz Template API

Tmplz Tags

Include Tags: Include

Here is a simple Include:

    And now I will....
    [$Include magic.html]
    ... surely you are impressed.  

This tells the parser to load magic.html, parse it, and insert its contents into the current template in place of the Include tag. Note that any Slots and Sections in magic.html become part of the current template as well.

Paths

In the example above, the Include specifies a "relative" path that says Tmplz should look for magic.html in the same directory as the current file. Depending on how one sets up Tmplz, a variety of path types can be used; for example, URL path's like http://myserver/magic.html or file://c/templates/magic.html. A computer programmer can set up Tmplz to support such paths and even implement a custom TextLoaderFactory to handle paths that require specialized processing. Several built-in TextLoaderFactories are included in the Tmplz distribution.

Including a Specific Section

Sometimes it is desirable to only include a specific Section from another document:

  [$Include ../special.html ThePartAboutPaleontology]

The above assumes that a Section named "ThePartAboutPaleontology" exists in the file special.html. The contents of that Section will be inserted into the current template (without the "ThePartAboutPaleontology" Section tag).

Nested tags

Includes can have both a starting and ending tag:

    [$Include ../includes/magic.html]
    ...
    [$Include]  

This syntax is used with nested tags, specifically: Fillin, Show, Rename and Remove, which are described in the next chapters.

Space Characters in Paths and Double Quotes

When including a path that has "whitespace" characters in it, and specifying a Section to include, quotes should be used; for example:

  [$Include "../special file about something.html" ThePartAboutPaleontology]

Without the quote marks, the path would be assumed to be ../special, and the Section name as file about something.html ThePartAboutPaleontology.

Next page: Fillin