4. The include tag

There is one tag that we haven't discussed yet and that is the I tag. It is used to include another template into the current one, we call it the include tag. This tag can be very useful when, for example, there is a standard page that all the pages of a site should use. Then it's just a matter of designing the standard page and telling the other templates to include it and to override certain value tags. Here is an example of a site that uses a "page" template to define a common header, footer and main menu.

Example 4.3. Template that can be used as a standard page, page.html

    <title><!--V 'window_title'-->the window title<!--/V--></title>
    <link rel="stylesheet" type="text/css" href="/style/site.css"/>

    <div id="menu">

      <a class="[!V 'menu_home']inactive[!/V]" 
         href="[!V 'EXIT:QUERY:home'/]">HOME</a>

      <a class="[!V 'menu_other']inactive[!/V]" 
         href="[!V 'EXIT:QUERY:other'/]"OTHER</a>


    <!--V 'page_content'-->content goes here<!--/V-->


In our different pages "Home" and "Other" we want to have a menu that highlights the name of the current page. This makes it easy for the user to find his way around the site. Different CSS classes are used in the menu to define the visual aspect of the menu items. They can either be active or inactive.

In Example 4.3, “Template that can be used as a standard page, page.html” we are using value tags with the names menu_home and menu_other to control the CSS classes of the menu links. The default value is set to be "inactive", meaning that the page is not shown.

We want to use this boiler-plate for both of our pages and therefore we need to include it from both pages. As mentioned, this is done by using the I tag.

Example 4.4. Including another page with the I-tag, home.html

<!--I 'page'/-->

<!--BV 'menu_home'-->active<!--/BV-->

<!--BV 'page_content'-->
My content on the Home page

We include the template "page" defined in Example 4.3, “Template that can be used as a standard page, page.html” by using the I tag. Then we set the default of menu_home to be "active" and page_content to be "My content on the Home page". By using this approach you can easily build a site with lots of pages but still only have to edit one file if you want to change the menu or the page content.