← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:10 2021

Filename/usr/local/lib/perl5/site_perl/mach/5.32/Template/Config.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sTemplate::Config::::BEGIN@21 Template::Config::BEGIN@21
0000s0sTemplate::Config::::BEGIN@22 Template::Config::BEGIN@22
0000s0sTemplate::Config::::BEGIN@23 Template::Config::BEGIN@23
0000s0sTemplate::Config::::constants Template::Config::constants
0000s0sTemplate::Config::::context Template::Config::context
0000s0sTemplate::Config::::filters Template::Config::filters
0000s0sTemplate::Config::::instdir Template::Config::instdir
0000s0sTemplate::Config::::iterator Template::Config::iterator
0000s0sTemplate::Config::::load Template::Config::load
0000s0sTemplate::Config::::parser Template::Config::parser
0000s0sTemplate::Config::::plugins Template::Config::plugins
0000s0sTemplate::Config::::preload Template::Config::preload
0000s0sTemplate::Config::::provider Template::Config::provider
0000s0sTemplate::Config::::service Template::Config::service
0000s0sTemplate::Config::::stash Template::Config::stash
0000s0sTemplate::TieString::::PRINTTemplate::TieString::PRINT
0000s0sTemplate::TieString::::TIEHANDLETemplate::TieString::TIEHANDLE
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#============================================================= -*-perl-*-
2#
3# Template::Config
4#
5# DESCRIPTION
6# Template Toolkit configuration module.
7#
8# AUTHOR
9# Andy Wardley <abw@wardley.org>
10#
11# COPYRIGHT
12# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
13#
14# This module is free software; you can redistribute it and/or
15# modify it under the same terms as Perl itself.
16#
17#========================================================================
18
19package Template::Config;
20
21use strict;
22use warnings;
23use base 'Template::Base';
24
25our $VERSION = '3.009';
26
27our $DEBUG;
28$DEBUG = 0 unless defined $DEBUG;
29our $ERROR = '';
30our $CONTEXT = 'Template::Context';
31our $FILTERS = 'Template::Filters';
32our $ITERATOR = 'Template::Iterator';
33our $PARSER = 'Template::Parser';
34our $PLUGINS = 'Template::Plugins';
35our $PROVIDER = 'Template::Provider';
36our $SERVICE = 'Template::Service';
37our $STASH;
38$STASH = 'Template::Stash::XS';
39our $CONSTANTS = 'Template::Namespace::Constants';
40
41our $LATEX_PATH;
42our $PDFLATEX_PATH;
43our $DVIPS_PATH;
44
45our @PRELOAD = ( $CONTEXT, $FILTERS, $ITERATOR, $PARSER,
46 $PLUGINS, $PROVIDER, $SERVICE, $STASH );
47
48# the following is set at installation time by the Makefile.PL
49our $INSTDIR = '';
50
51
52#========================================================================
53# --- CLASS METHODS ---
54#========================================================================
55
56#------------------------------------------------------------------------
57# preload($module, $module, ...)
58#
59# Preloads all the standard TT modules that are likely to be used, along
60# with any other passed as arguments.
61#------------------------------------------------------------------------
62
63sub preload {
64 my $class = shift;
65
66 foreach my $module (@PRELOAD, @_) {
67 $class->load($module) || return;
68 };
69 return 1;
70}
71
72
73#------------------------------------------------------------------------
74# load($module)
75#
76# Load a module via require(). Any occurrences of '::' in the module name
77# are be converted to '/' and '.pm' is appended. Returns 1 on success
78# or undef on error. Use $class->error() to examine the error string.
79#------------------------------------------------------------------------
80
81sub load {
82 my ($class, $module) = @_;
83 $module =~ s[::][/]g;
84 $module .= '.pm';
85 return 1 if $INC{$module};
86 eval { require $module; };
87 return $@ ? $class->error("failed to load $module: $@") : 1;
88}
89
90
91#------------------------------------------------------------------------
92# parser(\%params)
93#
94# Instantiate a new parser object of the class whose name is denoted by
95# the package variable $PARSER (default: Template::Parser). Returns
96# a reference to a newly instantiated parser object or undef on error.
97# The class error() method can be called without arguments to examine
98# the error message generated by this failure.
99#------------------------------------------------------------------------
100
101sub parser {
102 my $class = shift;
103 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
104 ? shift : { @_ };
105
106 return undef unless $class->load($PARSER);
107 return $PARSER->new($params)
108 || $class->error("failed to create parser: ", $PARSER->error);
109}
110
111
112#------------------------------------------------------------------------
113# provider(\%params)
114#
115# Instantiate a new template provider object (default: Template::Provider).
116# Returns an object reference or undef on error, as above.
117#------------------------------------------------------------------------
118
119sub provider {
120 my $class = shift;
121 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
122 ? shift : { @_ };
123
124 return undef unless $class->load($PROVIDER);
125 return $PROVIDER->new($params)
126 || $class->error("failed to create template provider: ",
127 $PROVIDER->error);
128}
129
130
131#------------------------------------------------------------------------
132# plugins(\%params)
133#
134# Instantiate a new plugins provider object (default: Template::Plugins).
135# Returns an object reference or undef on error, as above.
136#------------------------------------------------------------------------
137
138sub plugins {
139 my $class = shift;
140 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
141 ? shift : { @_ };
142
143 return undef unless $class->load($PLUGINS);
144 return $PLUGINS->new($params)
145 || $class->error("failed to create plugin provider: ",
146 $PLUGINS->error);
147}
148
149
150#------------------------------------------------------------------------
151# filters(\%params)
152#
153# Instantiate a new filters provider object (default: Template::Filters).
154# Returns an object reference or undef on error, as above.
155#------------------------------------------------------------------------
156
157sub filters {
158 my $class = shift;
159 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
160 ? shift : { @_ };
161
162 return undef unless $class->load($FILTERS);
163 return $FILTERS->new($params)
164 || $class->error("failed to create filter provider: ",
165 $FILTERS->error);
166}
167
168
169#------------------------------------------------------------------------
170# iterator(\@list)
171#
172# Instantiate a new Template::Iterator object (default: Template::Iterator).
173# Returns an object reference or undef on error, as above.
174#------------------------------------------------------------------------
175
176sub iterator {
177 my $class = shift;
178 my $list = shift;
179
180 return undef unless $class->load($ITERATOR);
181 return $ITERATOR->new($list, @_)
182 || $class->error("failed to create iterator: ", $ITERATOR->error);
183}
184
185
186#------------------------------------------------------------------------
187# stash(\%vars)
188#
189# Instantiate a new template variable stash object (default:
190# Template::Stash). Returns object or undef, as above.
191#------------------------------------------------------------------------
192
193sub stash {
194 my $class = shift;
195 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
196 ? shift : { @_ };
197
198 return undef unless $class->load($STASH);
199 return $STASH->new($params)
200 || $class->error("failed to create stash: ", $STASH->error);
201}
202
203
204#------------------------------------------------------------------------
205# context(\%params)
206#
207# Instantiate a new template context object (default: Template::Context).
208# Returns object or undef, as above.
209#------------------------------------------------------------------------
210
211sub context {
212 my $class = shift;
213 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
214 ? shift : { @_ };
215
216 return undef unless $class->load($CONTEXT);
217 return $CONTEXT->new($params)
218 || $class->error("failed to create context: ", $CONTEXT->error);
219}
220
221
222#------------------------------------------------------------------------
223# service(\%params)
224#
225# Instantiate a new template context object (default: Template::Service).
226# Returns object or undef, as above.
227#------------------------------------------------------------------------
228
229sub service {
230 my $class = shift;
231 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
232 ? shift : { @_ };
233
234 return undef unless $class->load($SERVICE);
235 return $SERVICE->new($params)
236 || $class->error("failed to create context: ", $SERVICE->error);
237}
238
239
240#------------------------------------------------------------------------
241# constants(\%params)
242#
243# Instantiate a new namespace handler for compile time constant folding
244# (default: Template::Namespace::Constants).
245# Returns object or undef, as above.
246#------------------------------------------------------------------------
247
248sub constants {
249 my $class = shift;
250 my $params = defined($_[0]) && ref($_[0]) eq 'HASH'
251 ? shift : { @_ };
252
253 return undef unless $class->load($CONSTANTS);
254 return $CONSTANTS->new($params)
255 || $class->error("failed to create constants namespace: ",
256 $CONSTANTS->error);
257}
258
259
260#------------------------------------------------------------------------
261# instdir($dir)
262#
263# Returns the root installation directory appended with any local
264# component directory passed as an argument.
265#------------------------------------------------------------------------
266
267sub instdir {
268 my ($class, $dir) = @_;
269 my $inst = $INSTDIR
270 || return $class->error("no installation directory");
271 chop $inst while substr($inst,-1) eq '/';
272 $inst .= "/$dir" if $dir;
273 return $inst;
274}
275
276
277#========================================================================
278# This should probably be moved somewhere else in the long term, but for
279# now it ensures that Template::TieString is available even if the
280# Template::Directive module hasn't been loaded, as is the case when
281# using compiled templates and Template::Parser hasn't yet been loaded
282# on demand.
283#========================================================================
284
285#------------------------------------------------------------------------
286# simple package for tying $output variable to STDOUT, used by perl()
287#------------------------------------------------------------------------
288
289package Template::TieString;
290
291sub TIEHANDLE {
292 my ($class, $textref) = @_;
293 bless $textref, $class;
294}
295sub PRINT {
296 my $self = shift;
297 $$self .= join('', @_);
298}
299
- -
3021;
303
304__END__