Standard Template

The standard template comes with Rextile. It is located in templates/standard in the folder where you installed Rextile. It defines specialized _wrapper.rextinc and _wrapper.xhtml files, and a number of auxiliary files which make site administration easier. The standard template is a good example of how to use Rextile.

Site Structure

To use the standard template, your site will typically contain the following files:

_site.rb site root, indicates template to use
_settings.rb per folder settings (crumbs, for example)
_links.rextinc global link target definitions
style.css style sheet
index.rextile index of the root folder
other.rextile another document in the root folder
other.rb Ruby code specific to other.rextile
articles/_settings.rb per folder settings of a subfolder
articles/_links.rextinc per folder additional link target definitions
articles/index.rextile index of a subfolder
articles/article.rextile another document in a subfolder

_site.rb

References the standard template:

@template_path = "#{INSTALL_PATH}/templates/standard'

_settings.rb

Overrides per-folder settings, see templates/standard/_init.rb for an overview. You will mostly be adding to crumbs here to define the breadcrumbs navigation captions:

@crumbs << 'Rextile Docs'

_links.rextinc

Defines global link targets for deferred links. I strongly suggest you place them all in a central _links.rextinc file and use the form :-abbr for them. This way, Rextile automatically warns you about undefined deferred targets. You can define additional link targets for individual subfolders in local _links.rextinc files, too. Example:

[-rb]http://ruby-lang.org/
[-tex]http://en.wikipedia.org/wiki/Textile_%28markup_language%29
[-erb]http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/

other.rb

The standard template automatically includes the corresponding .rb at the top of every .rextile page if it exists. This makes the .rb file a convenient place for custom script code called by <%...%> blocks on the page.

style.css

Defines the styling of the site. Plain HTML is not particulary beautiful, so you will want to do this. To reference the style sheet, add something like the following to the site root’s _settings.rb:

@head_nodes << '<link rel="stylesheet" type="text/css" href="' + root_path + 'style.css" />'

Custom Header and Footer

To override header and footer elements, you can add your own versions of

This is much better than overriding _wrapper.xhtmlinc, because the latter contains quite a bit of code.

Document and Page Title

A rextile document ususally begins with an h1 title, like so:

h1. Example Document

Here goes...

_wrapper.xhtml uses this title for the <head><title> text, unless you override it by setting page_title in a script block, as in <% page_title = ‘My Title’ %>@.

Breadcrumbs Navigation

_wrapper.xhtml automatically adds breadcrumbs navigation to the header of every page (unless you change this by overriding _header.xhtml). The crumbs always point back to index.htm of the current folder (unless the current page is index.htm), and then to all of the index.htm of the outer folders. The captions used for the crumbs are added to the array crumbs in _settings.rb for each folder.

If you add a two-element array to crumbs instead of a single string, the first element of the two-element array is used as the crumb target, the second as the caption.

The breadcrumbs are built using the method breadcrumbs() defined in _globals.rb in the standard template.

Table Of Contents

Rextile has a simple command for constructing a TOC from the headings within a page:

<%= toc %>

The table at the top of this page was built like that. Note that

There is a special form, <%= toc from, to %>, which allows you to specify the heading level range to include.

You can also build local TOCs with this. <%= toc 4, 5 %> right here will give you:

First

This is just some place-holder text to show the effect.

One

Some text.

Two

More text.

Second

Final text here.

Graphviz

Rextile comes with a script that renders embedded graphviz source to SVG in the final HTML output. Example:

<%= dot(" a -> b -> c ") %>

Renders as:

G a a b b a->b c c b->c

Adding Custom Scripts

You may also want to add your own script functions for use in script blocks. I suggest you put the following into your root folder’s _settings.rb file:

require '_funcs.rb'

and then add your functions to _funcs.rb.