Skip navigation.
Software » web2help » web2help guide » The template

Personalizing the template


web2help comes with a simple but effective template.

If you don't like it, you can easily define a custom template. web2help uses genshi as a template engine, so you can refer to genshi documentation for advanced topics; but this help topic should be sufficient.

First, analyze the standard web2help template, placed in %programfiles%\web2help\template\template.html. As you can see, it is a standard HTML page, with some special "placeholders" like ${Markup(content)}.

Please note that the template must be a valid XML document, otherwise genshi will complain. This means that every open tag must be closed, that attributes values must be put inside quotation marks, etc.

The special "placeholders" are replaced by actual page text when the project is compiled. The following table shows the valid placeholders.

Placeholder
Description
$title Page title, as extracted from grabbed pages
${Markup(content)} Page content, as extracted from grabbed pages
$parent URL of the parent node in the TOC, if it exists; False, otherwise (see below)
$prev URL of the previous topic in the TOC (w.r.t. a depth-first search of the TOC tree), if it exists; False, otherwise (see below)
$next URL of the next topic in the TOC (w.r.t. a depth-first search of the TOC tree), if it exists; False, otherwise (see below)
<py:if test="parent">
  some-elements
</py:if>
Test node. If the placeholder named $parent is not Falsesome-elements is generated. Otherwise, nothing is generated. Thus, if the current TOC node has not a parent (or a prev or next node), the corresponding TOC navigation element is not generated.

N.B.: the first line of the template must be the following (it will be executed and discarded when the template is compiled):

<?python from genshi.core import Markup ?>

In your template you can embed external resources, such as images and CSS stylesheets. Remember to put the template and the resources in the same directory.

To set the path of your custom template, go to Project -> Properties.