|
NAMEAny::Template - provide a consistent interface to a wide array of templating languagesSYNOPSISuse Any::Template; my $template = new Any::Template({ Backend => 'HTML::Template', Filename => 'page.tmpl', Options => {'strict' => 0} }); my $output = $template->process($data); my $template2 = new Any::Template({ Backend => 'Text::Template', String => $template2_content }); $template->process($data, \*STDOUT); DESCRIPTIONThis module provides a simple, consistent interface to common templating engines so you can write code that is agnostic to the template language used in the presentation layer. This means you can allow your interface developers to work in the templating language they're happiest in or write code that works with legacy/in-house templating modules but can also be released onto CPAN and work with more standard CPAN templating systems.By its very nature, this interface only exposes pretty much the lowest common denominator of the template engine APIs. It does however provide a fairly rich set of input and output mechanisms, using native implementations where available and providing some default implementations to extend the default set offered by some templating modules. If you need the quirky features of a particular templating engine, then this may not be for you. Having said that, in some cases you may be able to encapsulate some of your logic in options passed into the adaptor classes (either rolling your own adaptors, or improving ours) to pull the relevant strings on the backend module. Templateing languages supported by backends supplied with this distribution can be found in the README (remember there may be others out there and you can always roll your own). METHODS
SUBROUTINES
ERROR HANDLINGIf an error occurs, an exception is raised with die(). You can use an eval block to handle the exception. $@ will contain an error message.CONSTRUCTOR OPTIONS
ENVIRONMENTIf you don't supply a Backend to the constructor, Any::Template looks for a default Backend in the ANY_TEMPLATE_DEFAULT environment variable. This allows you to retrofit Any::Template into legacy code without hard-coding a default templating language or forcing a backwardly-incompatible change to the interface of the code you are retrofitting into.CACHINGThis module doesn't have built-in caching, however the objects it creates are intended to be cachable (where possible the backends hold onto precompiled templates that can be fed any number of data structures). It's therefore up to you what caching strategy you use. In the spirit of "if you liked this, you might also like..." Cache and Cache::Cache offer a consistent interface to a number of different caching strategies.SEE ALSO
VERSION$Revision: 1.15 $ on $Date: 2006/04/18 08:32:26 $ by $Author: johna $AUTHORJohn Alden <cpan _at_ bbc _dot_ co _dot_ uk>COPYRIGHT(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
Visit the GSP FreeBSD Man Page Interface. |