5.1.8 Defining layout

We want the various pages in our application to share a common layout.
Kauri's template language has an interesting
"template inheritance" feature for this. You can
write a base template in which certain regions, called blocks, can be redefined
by child templates.

As part of generating the project, a layout template is already created for
you at:

module1/src/main/kauri/templates/layout.xml

If you open this file, you will see it contains the following blocks:

<t:block name="title"/>
and
<t:block name="content"/>

You can of course create as many blocks as you like, and freely choose their
names.

Now let's adjust our order pages to inherit from this base layout.

We will show this for the orders.html.xml, you can do the same thing for
{orderid}.html.xml

Everything outside the t:block elements will be ignored, the content of the
t:block elements will be inserted into the base template.

The attribute t:inherit is used to specify the base template. The special
module protocol is used to address your module's
resources, in the source tree this corresponds with everything below
module1/src/main/kauri

If you want to define variables that should be visible in all blocks, you
can define them inside the t:init element. In this case, we could as well have
defined the variable inside the content block, as that's the only place it is
used.

After you have made these changes, the pages will still pretty much look the
same. You can adjust the layout.xml to apply a more fancy style.