Make your own free website on Tripod.com

The NewsBruiser Templating System

Leonard Richardson <leonardr@segfault.org>
Version: 1.5.0

NewsBruiser has a simple templating system that allows you to customize the look of your entries on a per-notebook basis without changing the NewsBruiser code. If you can't make your entries look the way you want with CSS, you should be able to do it by changing the templates.

Editing templates

All of NewsBruiser's templates are editable under the "Templates" section of configure.cgi (follow the "Configure" link from the notebook index and then the "Templates" link).

Template format

NewsBruiser templates consist of HTML interspersed with template directives. All template directives consist of a percent sign and a one- or two-character command, for instance: %a or %CP or %c#. When a template is interpolated for an entry, its directives are replaced with the appropriate values for that entry (see a template's documentation below for a list of the valid directives for that template).

If you need a literal percent sign in your template (for instance, when expressing the width of a table element as a percent), you can use '%%'. NewsBruiser will not interpolate directives it doesn't recognize, so you don't need to use '%%' unless the character after your percent sign is a valid NewsBruiser directive character.

General directive information

In general, lowercase and non-alphabetic directives apply directly to the object being interpolated (for instance, an entry). Uppercase directives in a template trigger the interpolation of another template (if appropriate to the object being interpolated).

Universal directives

The following directives can be used in the entry template or any of its subtemplates:

Templates

The entry template

The entry template is used to display notebook entries on view.cgi, edit.cgi, category.cgi, this_month.ssi, etc. etc. Anywhere a notebook entry is rendered as HTML, the entry template controls what HTML is generated.

The entry template recognizes the following special directives:

The default entry template is as follows:

<p class="entry">%p <a name="%i" class="entryDate">%d</a>%A%T: <span class="entryText">%e</span></p>

If you want the same, but you want to alternate background colors for your entries, then uncomment the background-color attributes of the .entry2 directive in default.css and try this:

<p class="entry%2>%p <a name="%i" class="entryDate" width="100%">%d</a>%A%T: <span class="entryText">%e</span></p>

If you want a really simple entry template, with no permalink, author, title, or anchor, try this:

<p>%d: %e</p>

The title template

The title template is a sub-template of the entry template. It's displayed for an entry only if that entry has a title and the entry template contains the %T directive.

This template recognizes the following special directive:

The default title template is as follows:

<span class="entryTitle">%t</span>

The author template

The author template is a sub-template of the entry template. It's displayed for an entry only if that entry has a title and the entry template contains the %A directive.

This template recognizes the following special directive:

The default author template is as follows:

(<span class="entryAuthor">%a</span>)

The category list template

This template recognizes the following special directives:

The category template

This template is a sub-template of the category template. It is interpolated once for every category to which an entry belongs, when the %CP directive is found in the category list template.

This template recognizes the following special directives:

The default category template is as follows:

%, %cn

If you want to do a fancier category list, here's one suggestion. Set your category list template to this:

<div class="entryCategories">Filed under %c# categor%cs: <ol>%CP</ol></div>

And set your category template to this:

<li>%cn</li>

Back to the main documentation