Any-Template

 view release on metacpan or  search on metacpan

lib/Any/Template.pm  view on Meta::CPAN

$VERSION = sprintf"%d.%03d", q$Revision: 1.15 $ =~ /: (\d+)\.(\d+)/;

sub new {
	my($class, $options) = @_;
	DUMP("Any::Template constructor - options", $options);
	$options->{Options} = {} unless defined ($options->{Options}); #Ensure this key is present

	#Input checking	
	my $backend = $options->{Backend} || $ENV{ANY_TEMPLATE_DEFAULT} 
		or croak("You must nominate a Backend or set the ANY_TEMPLATE_DEFAULT environment variable");
	croak("Package name '$backend' looks incorrect") if($backend =~ /[^\w:]/);
	my @sources = qw(Filename Filehandle String);
	croak("You must supply one of: ".join(", ", @sources)) unless grep {defined $options->{$_}} @sources;
	
	#Load backend
	$backend = join("::", __PACKAGE__, 'Backend', $backend);	
	eval "require $backend";
	die($@) if($@);

	#Create object (containing backend)
	my $self = {};

lib/Any/Template.pm  view on Meta::CPAN

	Reference to a filehandle from which to read the template

=item Options

	A hashref of options passed to the backend templating engine

=back

=head1 ENVIRONMENT

If 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.

=head1 CACHING

This 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..."
L<Cache> and L<Cache::Cache> offer a consistent interface to a number of different caching strategies.



( run in 0.307 second using v1.01-cache-2.11-cpan-64827b87656 )