O'Reilly logo

Running Weblogs with Slash by David Krieger, Brian Aker, Chromatic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. The Slash Template Language

Since Version 2.0, Slash has used Andy Wardley’s excellent Template Toolkit (http://www.template-toolkit.org/) to separate content from presentation. This allows Authors and administrators to change the look and feel of the site without having to modify large amounts of Perl code. Of course, this does require learning a little bit about the Template Toolkit language, as well as a few Slash-specific additions.

Template Basics

Templates are text files with embedded rules for including and formatting variable data. These rules are called directives. The simplest directives merely tell the template processor to insert the contents of a named variable in the current location. (If it helps, think of them as serious “Mad-Libs”.) A sample template might be:

Hello, [% name %].  How are you today?

If “Pater” were provided as the name variable, the output would be:

Hello, Pater.  How are you today?

Directives always occur within special tags so that the template processor and the readers can distinguish between regular text and instructions. The default Slash templates always use tags of the style [% DIRECTIVE %]. Each tag can contain multiple directives, separated by a semicolon. For clarity’s sake, most of the examples in this appendix will use the more verbose style.

Variables (and templates) aren’t limited to plain text. They can contain anything from HTML to XML to PostScript. In a Slash context, variables generally hold either plain text from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required