auto
  G   ˆl–Ðz¾”êe¶¥ ´ ™¸Ë÷%1hßÃ„.	Ÿ_‹uÐb&=LV[(a–Ãa¾”êe¶¥8 Cq·®Õ1hßÂ 57    #============================================================= -*-perl-*-
#
# Template::Config
#
# DESCRIPTION
#   Template Toolkit configuration module.
#
# AUTHOR
#   Andy Wardley   <abw@wardley.org>
#
# COPYRIGHT
#   Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
#
#   This module is free software; you can redistribute it and/or
#   modify it under the same terms as Perl itself.
#
#========================================================================
 
package Template::Config;

use strict;
use warnings;
use base 'Template::Base';
use vars qw( $VERSION $DEBUG $ERROR $INSTDIR
             $PARSER $PROVIDER $PLUGINS $FILTERS $ITERATOR 
             $LATEX_PATH $PDFLATEX_PATH $DVIPS_PATH
             $STASH $SERVICE $CONTEXT $CONSTANTS @PRELOAD );

$VERSION   = 2.75;
$DEBUG     = 0 unless defined $DEBUG;
$ERROR     = '';
$CONTEXT   = 'Template::Context';
$FILTERS   = 'Template::Filters';
$ITERATOR  = 'Template::Iterator';
$PARSER    = 'Template::Parser';
$PLUGINS   = 'Template::Plugins';
$PROVIDER  = 'Template::Provider';
$SERVICE   = 'Template::Service';
$STASH     = 'Template::Stash::XS';
$CONSTANTS = 'Template::Namespace::Constants';

@PRELOAD   = ( $CONTEXT, $FILTERS, $ITERATOR, $PARSER,
               $PLUGINS, $PROVIDER, $SERVICE, $STASH );

# the following is set at installation time by the Makefile.PL 
$INSTDIR  = '';


#========================================================================
#                       --- CLASS METHODS ---
#========================================================================

#------------------------------------------------------------------------
# preload($module, $module, ...)
#
# Preloads all the standard TT modules that are likely to be used, along
# with any other passed as arguments.
#------------------------------------------------------------------------

sub preload {
    my $class = shift;

    foreach my $module (@PRELOAD, @_) {
        $class->load($module) || return;
    };
    return 1;
}


#------------------------------------------------------------------------
# load($module)
#
# Load a module via require().  Any occurences of '::' in the module name
# are be converted to '/' and '.pm' is appended.  Returns 1 on success
# or undef on error.  Use $class->error() to examine the error string.
#------------------------------------------------------------------------

sub load {
    my ($class, $module) = @_;
    $module =~ s[::][/]g;
    $module .= '.pm';
    eval { require $module; };
    return $@ ? $class->error("failed to load $module: $@") : 1;
}


#------------------------------------------------------------------------
# parser(\%params)
#
# Instantiate a new parser object of the class whose name is denoted by
# the package variable $PARSER (default: Template::Parser).  Returns
# a reference to a newly instantiated parser object or undef on error.
# The class error() method can be called without arguments to examine
# the error message generated by this failure.
#------------------------------------------------------------------------

sub parser {
    my $class  = shift;
    my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
               ? shift : { @_ };

    return undef unless $class->load($PARSER);
    return $PARSER->new($params) 
        || $class->error("failed to create parser: ", $PARSER->error);
}


#------------------------------------------------------------------------
# provider(\%params)
#
# Instantiate a new template provider object (default: Template::Provider).
# Returns an object reference or undef on error, as above.
#------------------------------------------------------------------------

sub provider {
    my $class  = shift;
    my $params = defined($_[0]) && ref($_[0]) eq 'HASH' 
               ? shift : { @_ };

    return undef unless $class->load($PROVIDER);
    return $PROVIDER->new($params) 
        || $class->error("failed to create template provider: ",
                         $PROVIDER->error);
}


#-----------