[Image: The IceFrog]

Extensions to Template Toolkit

High Programmer > Alan De Smet > IceFrog > Documentation > Extensions to Template Toolkit

IceFrog is built on top of Template Toolkit and adds a number of useful extensions.

Tags

You can use the default Template Toolkit tags markers of [% %], or you can use the IceFrog additions <!--% %--> [% %] is useful when you want the tags to appear when you're previewing the template in your web browser, while <!--% %--> is useful when you don't want to see the tags.

PATHTO

IceFrog adds a new procedure, PATHTO. PATHTO takes the path (from the template file!) to another file. When the template is transformed into the output file, the relative path from the output file to the target file will be created. If your template will be creating multiple directories of output, this is the easiest way to ensure that your links to static items (like other pages or graphics) remain correct. Here's a common example that ensures that the image for the Gnomovision logo is always correctly defined.

<img src="[% PATHTO("../gnomovision_logo.jpg"> %]">
<h1>Gnomovision</h1>

Variables

All of the values set in your IceFrog Input (ifi) files are visible. So if you specified

title: About Gnomovision
in your input file, the template will have the variable "title" available with the value "About Gnomovision".

DB variables (like {db_ifi}) will be available as a list. You'll usually want to use FOREACH to spin over the list.

IceFrog automatically builds a list of "parent" pages and stores it in the variable "parents". This variable is a list, to implement a breadcrumb trail, something like the following will do the job. (This is the exact code used to generate the breadcrumb trails on the IceFrog web pages as of July, 2003.)

<!--% IF parents.size %-->
<div class="divbox">
<!--% FOREACH parent = parents -%-->
<A HREF="[% parent.relativeurl %]">[% parent.title %]</A>
<!--% " > " IF ! loop.last -%-->
<!--% END -%-->
 > [% title %]
</div>
<!--% END %-->

You may notice variables which begin with ICEFROG. These variables are only for IceFrog's internal use. They may disappear or change meaning in future IceFrog releases. If there is information you see in an ICEFROG variable that you would like available to your template, let me know and I'll see about adding a public version.

Contact webmaster