Using Rextile

Running Rextile

Rextile is an offline site-construction tool that works on files and folders. Running it is very simple. Just change to your site’s root folder and issue:

/path/to/rextile/rextile

Here’s what this does:

How .rextile Files Are Processed

For each .rextile file, Rextile processes first the Textile form, then the XHTML form.

Textile Processing

XHTML Processing

XHTML Script Node Processing

Out-of-order Processing

You can instruct Rextile to process a file during the processing of another file. This is handy when automatically building listings of other files in index pages, for example. To do this, just say process 'my/path/myfile.rextile' within an embedded script. Rextile maintains a list of files already processed so files don’t get processed twice.

You can see this in action in the file sample/articles/index.rb.

File Lookup

When Rextile looks for the wrapper files _wrapper.rextinc and _wrapper.xhtml, it uses the method read_closest_file() to do so. This method looks in the current .rextile file’s folder, and then in all its parent folders up to the site root. Finally, it looks in template_path. It returns the first matching file. This means you can override the files at every folder level of your site.

The standard template also makes use of this method to find auxiliary files like, for example, _init.rb.

There are two other, related methods, that concatenate all of the files, rather than just returning the first match. They are

The standard template uses the former to read _settings.rb. This means that inner settings are evaluated last and thus have precendence.

Dependency Checking

Largish sites can take quite a while to build. To speed up the repeated rebuilds while you’re developing content, you can make Rextile keep track of which files need to be regenerated. To enable this, add to your _site.rb a line like the following:

@dependency_info = '/path/to/rextile.deps'

Rextile will then store information on what files depend on which other file versions in that file and only rebuild out-of-date files on subsequent runs.

Accessing External Files

To enable dependency checking, you have to make sure that you read external files used by your inlined scripts using the file-reading functions provided by Rextile as described above. To build folder indices, use glob( pattern ) and read_file( name ), again as provided by Rextile.

Sample Wrapper Files

_wrapper.rextinc

The Rextile wrapper file, if present, is used to define a common header and footer for every page. Rextile simply uses the wrapper file’s source and, within it, replaces the sequence CONTENT GOES HERE by the page’s source text. For example:

p=. Header

CONTENT GOES HERE

p=. Footer

More typical than this contrived example is putting a script block in the header part where you initialize custom instance variables and require global modules. Those can then be used in script blocks within the pages themselves, and in the HTML script blocks in _wrapper.xhtml. See the standard template for a more elaborate example.

_wrapper.xhtmlinc

The XHTML wrapper file, if present, defines the common XHTML header and footer for every page. Rextile simply uses the wrapper file’s source and, within it, replaces the sequence CONTENT GOES HERE by the body XHTML produced for the page. For example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>

CONTENT GOES HERE

</body>
</html>

Using XHTML script blocks of the form <%...%> here is very handy. See the standard template for a more elaborate example.