Include files

You will often want to use the same piece of code in different template files.

This can be easily done by putting the common code into its own file and then using the {%INCLUDE%} tag to insert the contents of that file into the template when it is needed.

 

Awasu uses this feature heavily, putting the bulk of the template code into a separate file that is then included by whoever needs it.

For example, the Rusty.template file looks like this:

<html>

<head>
    {%INCLUDE% includes/StandardHead.include}
    <style>
        {%INCLUDE% Rusty.css}
        {%INCLUDE% Rusty.user.css isOptional} [1]
    </style>
    {%INCLUDE% includes/StandardHead2.include}
</head>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<body>
    {%INCLUDE% includes/StandardBody.include}
</body>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

</html>

In each case, the {%INCLUDE%} tag is replaced with contents of the specified file.

Hint
The ProcessTemplateIncludes.py utility script is provided that expands out all {%INCLUDE%} tags to produce a single big file. This is useful if you want to use one of the existing templates as a starting point and change it without affecting anything else.

 

The special {%BASE-DIR-URL%} template parameter is updated each time to point to the base URL that the template file currently being processed lives in. This allows template files to reference external resources such as images.

For example, from Rusty.css:

.banner
{
    background-image: url( "{%BASE-DIR-URL% encode=attr}/images/Rusty/banner.png" ) ;
    background-repeat: repeat-x ;
    border: 3px double ;
    padding: 10px ;
    color: #fff ;
}