Koha ILS

KohaCon10: Template Toolkit

By Reed Wade. Slides can be found here.

A perl module for template rendering. Create an environment, then call a template file. The template can call functions and variables you’ve provided, as well as other templates. Filters let you apply other conversions, like HTML escaping.

Support for IF/ELSE and FOREACH, of course.

Values can be passed through filters like HTML, or custom filters. This can let us format data without XSLT sheets. Filters can wrap entire sections of the template, so you can HTML escape by default until you don’t want to.

Planning is very important; these files need to be organized for optimal understanding. Think reusability and maintainability. Don’t put too many files in a single directory; you can nest. Use common indentation and coding standards.

Normally, your template-rendered code will come through as blank lines in the HTML once rendered. You can use a ‘-‘ in the template tag to prevent this. Other filters for this are available, too.

Learn more at http://template-toolkit.org.

For Koha’s switch to Template Toolkit, we will run an automated script, then Catalyst will have a student do cleanup and error checking. Once this is mostly complete, the Release Manager will no longer allow HTML::Template-based patches. Approximate timeframe: 1-2 months. Certainly by Koha 3.4.


[Originally posted by Ian Walls]

Read more by ByWater Staff

Tags kohacon10