4. Constructing module templates

Let's take a look, how to create templates for website modules. In this case, we cannot render prologs and document type definitions, so our basic tool will be opt:root:

<?xml version="1.0" ?>
<opt:root>
  <h1>News</h1>
  <p>A news page</p>
  <opt:section name="news">
    ...
  </opt:section>
</opt:root>

Similarly to the previous chapter, the XML prolog we can see is not rendered but used for internal purposes by OPT (it does not mean that it may contain a nonsense - the compiler validates both syntax and the contents). Thanks to opt:root we can put more than one tag in the content. Moreover, this instruction allows to specify the HTML escaping rules for the template and load an extra template with snippets that can be used in our code:

<?xml version="1.0" ?>
<opt:root escaping="yes" include="snippets.tpl">
  <h1>News</h1>
  <p>A news page</p>
  <opt:section name="news">
    ...
  </opt:section>
 
  <!-- paste a default pagination snippet from snippets.tpl -->
  <opt:insert snippet="pagination" />
</opt:root>

Because of that, opt:root is worth having in every template, even if we disabled a certain compiler option for checking the root nodes.