IntraWeb Archive

XI – IPM Templates

XI – IPM Templates

IPM supports templates, sometimes also known as skins, or master pages. This allows a common look to be applied to all pages. These are not simple templates however, and support cascading and many other features.


This is from the current “Website” demo available on Codeplex. Likely it will change drastically before release, so whats contained in this entry may not match what you find in the demo at the time you look.


Here is a very boring looking page named index.html.


But we want to give it a uniform look, so we have desinged this template.

The var and sys variables are covered in the variables topic. For templates we have some additional variables which use the Template prefix.

Template Variables


Title is the title extracted from the title attribute in the HEAD section of the page, if one exists. If not it will be replaced with an empty string.


From the target page, the contents between the body tags will be extracted and replaced as contents of the Template.Body variable.


When the index.html page is requested, it will be merged with the template and the final output will appear as follows:

The final result is that they have been merged.


When IntraWeb serves a page, it looks for a matching template. Templates are searched for in the following manner:

  1. See if there is a config file for the document. If so, obtain path and/or name from the config file.
  2. If no path is specified, or no config file exists, start searching in the same directory as the page.
  3. If no template name is specified, or no config file exists, ‘Default’ is the default.
  4. If a matching template by name is not found in the page directory, the directory above is searched. This is repeated until the web root directory is reached.
  5. If no matching template is found, none will be used.

Template Names

Templates are stored on disk as #Tmplt.<Name>.html and they can also have an associated config file. For example, a template called Silver would have a filename of #Tmplt.Silver.html. The default template then is #Tmplt.Default.html.


Templates can be cascaded by specifying a parent template in the template config. In such a case, the child template is merged into the parent template in the Template.Body tag, and then the page is merged into that merged template. Templates can have both children and parents, so the merging process can happen through several levels.

For example, this template is in /Team/ and is named Default. It exists on disk as wwwroot/Team/#Tmplt.Default.html.

It has a config file (/wwwroot/Team/#Tmplt.Default.cfg) with the following contents:


In /wwwroot/ is the parent template (/wwwroot/#Tmplt.Default.cfg):

When we request /Team/Jack.html, we end up the Team/Default template inside the root template, and then merged with the page.

/Team/index.html however uses just the root template, not the Team/Default template beause its index#.cfg file contains the following:


This is explained in page config files.

URL Resolution

During template design, a template may reference other URLs including links, images, CSS, and other such files. Templates are not served from their stored location, but the location of the page they are applied to. To make design simpler, templates are scanned and any relative URLs are rewritten and a prefix is inserted that specifies where the template physically exists. This makes the template perform at run time as it does at design time. In the case of cascading templates, each template part will be rewritten with a separate prefix to match its source location.