1Template::Config(3)   User Contributed Perl Documentation  Template::Config(3)
2
3
4

NAME

6       Template::Config - Factory module for instantiating other TT2 modules
7

SYNOPSIS

9           use Template::Config;
10

DESCRIPTION

12       This module implements various methods for loading and instantiating
13       other modules that comprise the Template Toolkit.  It provides a con‐
14       sistent way to create toolkit components and allows custom modules to
15       be used in place of the regular ones.
16
17       Package variables such as $STASH, $SERVICE, $CONTEXT, etc., contain the
18       default module/package name for each component (Template::Stash, Tem‐
19       plate::Service and Template::Context, respectively) and are used by the
20       various factory methods (stash(), service() and context()) to load the
21       appropriate module.  Changing these package variables will cause subse‐
22       quent calls to the relevant factory method to load and instantiate an
23       object from the new class.
24

PUBLIC METHODS

26       load($module)
27
28       Load a module via require().  Any occurences of '::' in the module name
29       are be converted to '/' and '.pm' is appended.  Returns 1 on success or
30       undef on error.  Use $class->error() to examine the error string.
31
32       preload()
33
34       This method preloads all the other Template::* modules that are likely
35       to be used.  It is called by the Template module when running under
36       mod_perl ($ENV{MOD_PERL} is set).
37
38       parser(\%config)
39
40       Instantiate a new parser object of the class whose name is denoted by
41       the package variable $PARSER (default: Template::Parser).  Returns a
42       reference to a newly instantiated parser object or undef on error.
43
44       provider(\%config)
45
46       Instantiate a new template provider object (default: Tem‐
47       plate::Provider).  Returns an object reference or undef on error, as
48       above.
49
50       plugins(\%config)
51
52       Instantiate a new plugins provider object (default: Template::Plugins).
53       Returns an object reference or undef on error, as above.
54
55       filters(\%config)
56
57       Instantiate a new filter provider object (default: Template::Filters).
58       Returns an object reference or undef on error, as above.
59
60       stash(\%vars)
61
62       Instantiate a new stash object (Template::Stash or Template::Stash::XS
63       depending on the default set at installation time) using the contents
64       of the optional hash array passed by parameter as initial variable def‐
65       initions.  Returns an object reference or undef on error, as above.
66
67       context(\%config)
68
69       Instantiate a new template context object (default: Template::Context).
70       Returns an object reference or undef on error, as above.
71
72       service(\%config)
73
74       Instantiate a new template service object (default: Template::Service).
75       Returns an object reference or undef on error, as above.
76
77       instdir($dir)
78
79       Returns the root directory of the Template Toolkit installation under
80       which optional components are installed.  Any relative directory speci‐
81       fied as an argument will be appended to the returned directory.
82
83           # e.g. returns '/usr/local/tt2'
84           my $ttroot = Template::Config->instdir()
85               ⎪⎪ die "$Template::Config::ERROR\n";
86
87           # e.g. returns '/usr/local/tt2/templates'
88           my $template = Template::Config->instdir('templates')
89               ⎪⎪ die "$Template::Config::ERROR\n";
90
91       Returns undef and sets $Template::Config::ERROR appropriately if the
92       optional components of the Template Toolkit have not been installed.
93

AUTHOR

95       Andy Wardley <abw@wardley.org>
96
97       <http://wardley.org/http://wardley.org/>
98

VERSION

100       2.74, distributed as part of the Template Toolkit version 2.18,
101       released on 09 February 2007.
102
104         Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
105
106       This module is free software; you can redistribute it and/or modify it
107       under the same terms as Perl itself.
108

SEE ALSO

110       Template
111
112
113
114perl v5.8.8                       2007-02-09               Template::Config(3)
Impressum