Template Language

The Template Language is markup (we will call it TML) language that provides a means of interacting with the CMS database whilst the page is rendering on the server.

The language is interleaved with XHTML elements that the template should render, and can provide some dynamic page functionality.

Custom Parsers / Controls

The template language exposes a set of controls / parsers that interact with the CMS and rendering page. These are accessed using XML namespaces, e.g <page:repeater></page:repeater> will put a page:repeater parser in the template.

Template Context

As the template is rendering it keeps a stack of values that can be accessed via the template markup. At the top of the stack is the current page. Properties from the values in the stack can be rendered or used in the template by escaping the values with curly brackets.

E.g:

{Page.Name} will be substituted for the name of the page on the top of the context stack

Or in XHTML:

 <a href="{Page.Url}">{Page.Name}</a>

Will provide a link to the page on the top of the context stack.

Some parsers provide visual output, but the visual output can also be redirected onto the stack, and used in subsequent elements of the template, e.g <page:property /> would render a property on the template, however if <page:property/> contained nested markup the output would be pushed onto the top of the context stack instead, this allows for manipulation of values prior to rendering.

e.g
<ul>
    <page:property name="SomeMultilinePropertyText"/>
        <string:split>
            <string:output Tag="li">
        </string:split>
    </page:property>
<ul>


In the above example, the value of SomeMultilinePropertyText is pushed on to the context stack, and then split by the <string:split> parser which the result is pushed onto the context stack, and the resulting split string is ouput into a number of <li> elements.

If the value onto of the stack is not compatible as an input parameter of the parser, it will look further down the stack until it finds the first value it can use, and continue, if it can not find a value, some parsers will raise an error during runtime.

Last edited Jun 13, 2011 at 4:54 PM by methodworx, version 6

Comments

No comments yet.