| 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-2022 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 | |||||||||||||||||||||||||||||
| 19 | package Template::Config; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 117 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 117 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 117 | ▶ | use base 'Template::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 117 | our $VERSION = '3.106'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 117 | our $DEBUG; | |||||||||||||||||||||||||||
| 28 | 117 | ▶ | $DEBUG = 0 unless defined $DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 117 | our $ERROR = ''; | |||||||||||||||||||||||||||
| 30 | 117 | our $CONTEXT = 'Template::Context'; | |||||||||||||||||||||||||||
| 31 | 117 | our $FILTERS = 'Template::Filters'; | |||||||||||||||||||||||||||
| 32 | 117 | our $ITERATOR = 'Template::Iterator'; | |||||||||||||||||||||||||||
| 33 | 117 | our $PARSER = 'Template::Parser'; | |||||||||||||||||||||||||||
| 34 | 117 | our $PLUGINS = 'Template::Plugins'; | |||||||||||||||||||||||||||
| 35 | 117 | our $PROVIDER = 'Template::Provider'; | |||||||||||||||||||||||||||
| 36 | 117 | our $SERVICE = 'Template::Service'; | |||||||||||||||||||||||||||
| 37 | 117 | our $STASH; | |||||||||||||||||||||||||||
| 38 | 117 | $STASH = 'Template::Stash::XS'; | |||||||||||||||||||||||||||
| 39 | 117 | our $CONSTANTS = 'Template::Namespace::Constants'; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 117 | our $LATEX_PATH; | |||||||||||||||||||||||||||
| 42 | 117 | our $PDFLATEX_PATH; | |||||||||||||||||||||||||||
| 43 | 117 | our $DVIPS_PATH; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 117 | our @PRELOAD = ( | |||||||||||||||||||||||||||
| 46 | $CONTEXT, $FILTERS, $ITERATOR, $PARSER, | ||||||||||||||||||||||||||||
| 47 | $PLUGINS, $PROVIDER, $SERVICE, $STASH | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # the following is set at installation time by the Makefile.PL | ||||||||||||||||||||||||||||
| 51 | 117 | our $INSTDIR = ''; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | #======================================================================== | ||||||||||||||||||||||||||||
| 55 | # --- CLASS METHODS --- | ||||||||||||||||||||||||||||
| 56 | #======================================================================== | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 59 | # preload($module, $module, ...) | ||||||||||||||||||||||||||||
| 60 | # | ||||||||||||||||||||||||||||
| 61 | # Preloads all the standard TT modules that are likely to be used, along | ||||||||||||||||||||||||||||
| 62 | # with any other passed as arguments. | ||||||||||||||||||||||||||||
| 63 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 3 | ▶ | sub preload { | ||||||||||||||||||||||||||
|
Subroutine
preload: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 3 | my $class = shift; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 3 | foreach my $module (@PRELOAD, @_) { | |||||||||||||||||||||||||||
| 69 | 26 | ▶ | $class->load($module) || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | }; | ||||||||||||||||||||||||||||
| 71 | 2 | return 1; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 76 | # load($module) | ||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||
| 78 | # Load a module via require(). Any occurrences of '::' in the module name | ||||||||||||||||||||||||||||
| 79 | # are be converted to '/' and '.pm' is appended. Returns 1 on success | ||||||||||||||||||||||||||||
| 80 | # or undef on error. Use $class->error() to examine the error string. | ||||||||||||||||||||||||||||
| 81 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 2143 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 2143 | my ($class, $module) = @_; | |||||||||||||||||||||||||||
| 85 | 2143 | $module =~ s[::][/]g; | |||||||||||||||||||||||||||
| 86 | 2143 | $module .= '.pm'; | |||||||||||||||||||||||||||
| 87 | 2143 | ▶ | return 1 if $INC{$module}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 529 | eval { require $module; }; | |||||||||||||||||||||||||||
| 89 | 529 | ▶ | return $@ ? $class->error("failed to load $module: $@") : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 94 | # parser(\%params) | ||||||||||||||||||||||||||||
| 95 | # | ||||||||||||||||||||||||||||
| 96 | # Instantiate a new parser object of the class whose name is denoted by | ||||||||||||||||||||||||||||
| 97 | # the package variable $PARSER (default: Template::Parser). Returns | ||||||||||||||||||||||||||||
| 98 | # a reference to a newly instantiated parser object or undef on error. | ||||||||||||||||||||||||||||
| 99 | # The class error() method can be called without arguments to examine | ||||||||||||||||||||||||||||
| 100 | # the error message generated by this failure. | ||||||||||||||||||||||||||||
| 101 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 231 | ▶ | sub parser { | ||||||||||||||||||||||||||
|
Subroutine
parser: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 231 | my $class = shift; | |||||||||||||||||||||||||||
| 105 | 231 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 106 | ? shift | ||||||||||||||||||||||||||||
| 107 | : { @_ }; | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 231 | ▶ | return undef unless $class->load($PARSER); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 231 | ▶ | return $PARSER->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::PARSER->new($params) || $class->error('failed to create parser: ', $Template::Config::PARSER->error)
MC/DC0%0/2
$Template::Config::PARSER->new($params) || $class->error('failed to create parser: ', $Template::Config::PARSER->error)
$Template::Config::PARSER->new($params)
$class->error('failed to create parser: ', $Template::Config::PARSER->error)
Truth table33%1/3
A || B
A= $Template::Config::PARSER->new($params)B= $class->error('failed to create parser: ', $Template::Config::PARSER->error)
| |||||||||||||||||||||||||||||
| 111 | || $class->error("failed to create parser: ", $PARSER->error); | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 116 | # provider(\%params) | ||||||||||||||||||||||||||||
| 117 | # | ||||||||||||||||||||||||||||
| 118 | # Instantiate a new template provider object (default: Template::Provider). | ||||||||||||||||||||||||||||
| 119 | # Returns an object reference or undef on error, as above. | ||||||||||||||||||||||||||||
| 120 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 268 | ▶ | sub provider { | ||||||||||||||||||||||||||
|
Subroutine
provider: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 268 | my $class = shift; | |||||||||||||||||||||||||||
| 124 | 268 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 125 | ? shift | ||||||||||||||||||||||||||||
| 126 | : { @_ }; | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 268 | ▶ | return undef unless $class->load($PROVIDER); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 268 | ▶ | return $PROVIDER->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::PROVIDER->new($params) || $class->error('failed to create template provider: ', $Template::Config::PROVIDER->error)
MC/DC0%0/2
$Template::Config::PROVIDER->new($params) || $class->error('failed to create template provider: ', $Template::Config::PROVIDER->error)
$Template::Config::PROVIDER->new($params)
$class->error('failed to create template provider: ', $Template::Config::PROVIDER->error)
Truth table33%1/3
A || B
A= $Template::Config::PROVIDER->new($params)B= $class->error('failed to create template provider: ', $Template::Config::PROVIDER->error)
| |||||||||||||||||||||||||||||
| 130 | || $class->error( | ||||||||||||||||||||||||||||
| 131 | "failed to create template provider: ", | ||||||||||||||||||||||||||||
| 132 | $PROVIDER->error | ||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 138 | # plugins(\%params) | ||||||||||||||||||||||||||||
| 139 | # | ||||||||||||||||||||||||||||
| 140 | # Instantiate a new plugins provider object (default: Template::Plugins). | ||||||||||||||||||||||||||||
| 141 | # Returns an object reference or undef on error, as above. | ||||||||||||||||||||||||||||
| 142 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 268 | ▶ | sub plugins { | ||||||||||||||||||||||||||
|
Subroutine
plugins: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | 268 | my $class = shift; | |||||||||||||||||||||||||||
| 146 | 268 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 147 | ? shift | ||||||||||||||||||||||||||||
| 148 | : { @_ }; | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 268 | ▶ | return undef unless $class->load($PLUGINS); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 268 | ▶ | return $PLUGINS->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::PLUGINS->new($params) || $class->error('failed to create plugin provider: ', $Template::Config::PLUGINS->error)
MC/DC0%0/2
$Template::Config::PLUGINS->new($params) || $class->error('failed to create plugin provider: ', $Template::Config::PLUGINS->error)
$Template::Config::PLUGINS->new($params)
$class->error('failed to create plugin provider: ', $Template::Config::PLUGINS->error)
Truth table33%1/3
A || B
A= $Template::Config::PLUGINS->new($params)B= $class->error('failed to create plugin provider: ', $Template::Config::PLUGINS->error)
| |||||||||||||||||||||||||||||
| 152 | || $class->error( | ||||||||||||||||||||||||||||
| 153 | "failed to create plugin provider: ", | ||||||||||||||||||||||||||||
| 154 | $PLUGINS->error | ||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 160 | # filters(\%params) | ||||||||||||||||||||||||||||
| 161 | # | ||||||||||||||||||||||||||||
| 162 | # Instantiate a new filters provider object (default: Template::Filters). | ||||||||||||||||||||||||||||
| 163 | # Returns an object reference or undef on error, as above. | ||||||||||||||||||||||||||||
| 164 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 268 | ▶ | sub filters { | ||||||||||||||||||||||||||
|
Subroutine
filters: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 167 | 268 | my $class = shift; | |||||||||||||||||||||||||||
| 168 | 268 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 169 | ? shift | ||||||||||||||||||||||||||||
| 170 | : { @_ }; | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 268 | ▶ | return undef unless $class->load($FILTERS); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 268 | ▶ | return $FILTERS->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::FILTERS->new($params) || $class->error('failed to create filter provider: ', $Template::Config::FILTERS->error)
MC/DC0%0/2
$Template::Config::FILTERS->new($params) || $class->error('failed to create filter provider: ', $Template::Config::FILTERS->error)
$Template::Config::FILTERS->new($params)
$class->error('failed to create filter provider: ', $Template::Config::FILTERS->error)
Truth table33%1/3
A || B
A= $Template::Config::FILTERS->new($params)B= $class->error('failed to create filter provider: ', $Template::Config::FILTERS->error)
| |||||||||||||||||||||||||||||
| 174 | || $class->error( | ||||||||||||||||||||||||||||
| 175 | "failed to create filter provider: ", | ||||||||||||||||||||||||||||
| 176 | $FILTERS->error | ||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 182 | # iterator(\@list) | ||||||||||||||||||||||||||||
| 183 | # | ||||||||||||||||||||||||||||
| 184 | # Instantiate a new Template::Iterator object (default: Template::Iterator). | ||||||||||||||||||||||||||||
| 185 | # Returns an object reference or undef on error, as above. | ||||||||||||||||||||||||||||
| 186 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 274 | ▶ | sub iterator { | ||||||||||||||||||||||||||
|
Subroutine
iterator: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 274 | my $class = shift; | |||||||||||||||||||||||||||
| 190 | 274 | my $list = shift; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 274 | ▶ | return undef unless $class->load($ITERATOR); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 274 | ▶ | return $ITERATOR->new($list, @_) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::ITERATOR->new($list, @_) || $class->error('failed to create iterator: ', $Template::Config::ITERATOR->error)
MC/DC0%0/2
$Template::Config::ITERATOR->new($list, @_) || $class->error('failed to create iterator: ', $Template::Config::ITERATOR->error)
$Template::Config::ITERATOR->new($list, @_)
$class->error('failed to create iterator: ', $Template::Config::ITERATOR->error)
Truth table33%1/3
A || B
A= $Template::Config::ITERATOR->new($list, @_)B= $class->error('failed to create iterator: ', $Template::Config::ITERATOR->error)
| |||||||||||||||||||||||||||||
| 194 | || $class->error("failed to create iterator: ", $ITERATOR->error); | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 199 | # stash(\%vars) | ||||||||||||||||||||||||||||
| 200 | # | ||||||||||||||||||||||||||||
| 201 | # Instantiate a new template variable stash object (default: | ||||||||||||||||||||||||||||
| 202 | # Template::Stash). Returns object or undef, as above. | ||||||||||||||||||||||||||||
| 203 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 274 | ▶ | sub stash { | ||||||||||||||||||||||||||
|
Subroutine
stash: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 206 | 274 | my $class = shift; | |||||||||||||||||||||||||||
| 207 | 274 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 208 | ? shift | ||||||||||||||||||||||||||||
| 209 | : { @_ }; | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 274 | ▶ | return undef unless $class->load($STASH); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 274 | ▶ | return $STASH->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::STASH->new($params) || $class->error('failed to create stash: ', $Template::Config::STASH->error)
MC/DC0%0/2
$Template::Config::STASH->new($params) || $class->error('failed to create stash: ', $Template::Config::STASH->error)
$Template::Config::STASH->new($params)
$class->error('failed to create stash: ', $Template::Config::STASH->error)
Truth table33%1/3
A || B
A= $Template::Config::STASH->new($params)B= $class->error('failed to create stash: ', $Template::Config::STASH->error)
| |||||||||||||||||||||||||||||
| 213 | || $class->error( | ||||||||||||||||||||||||||||
| 214 | "failed to create stash: ", | ||||||||||||||||||||||||||||
| 215 | $STASH->error | ||||||||||||||||||||||||||||
| 216 | ); | ||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 221 | # context(\%params) | ||||||||||||||||||||||||||||
| 222 | # | ||||||||||||||||||||||||||||
| 223 | # Instantiate a new template context object (default: Template::Context). | ||||||||||||||||||||||||||||
| 224 | # Returns object or undef, as above. | ||||||||||||||||||||||||||||
| 225 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 267 | ▶ | sub context { | ||||||||||||||||||||||||||
|
Subroutine
context: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||
| 228 | 267 | my $class = shift; | |||||||||||||||||||||||||||
| 229 | 267 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC100%2/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 230 | ? shift | ||||||||||||||||||||||||||||
| 231 | : { @_ }; | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 267 | ▶ | return undef unless $class->load($CONTEXT); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 267 | ▶ | return $CONTEXT->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::CONTEXT->new($params) || $class->error('failed to create context: ', $Template::Config::CONTEXT->error)
MC/DC0%0/2
$Template::Config::CONTEXT->new($params) || $class->error('failed to create context: ', $Template::Config::CONTEXT->error)
$Template::Config::CONTEXT->new($params)
$class->error('failed to create context: ', $Template::Config::CONTEXT->error)
Truth table33%1/3
A || B
A= $Template::Config::CONTEXT->new($params)B= $class->error('failed to create context: ', $Template::Config::CONTEXT->error)
| |||||||||||||||||||||||||||||
| 235 | || $class->error( | ||||||||||||||||||||||||||||
| 236 | "failed to create context: ", | ||||||||||||||||||||||||||||
| 237 | $CONTEXT->error | ||||||||||||||||||||||||||||
| 238 | ); | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 243 | # service(\%params) | ||||||||||||||||||||||||||||
| 244 | # | ||||||||||||||||||||||||||||
| 245 | # Instantiate a new template context object (default: Template::Service). | ||||||||||||||||||||||||||||
| 246 | # Returns object or undef, as above. | ||||||||||||||||||||||||||||
| 247 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 253 | ▶ | sub service { | ||||||||||||||||||||||||||
|
Subroutine
service: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 250 | 253 | my $class = shift; | |||||||||||||||||||||||||||
| 251 | 253 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 252 | ? shift | ||||||||||||||||||||||||||||
| 253 | : { @_ }; | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 253 | ▶ | return undef unless $class->load($SERVICE); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 253 | ▶ | return $SERVICE->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::SERVICE->new($params) || $class->error('failed to create context: ', $Template::Config::SERVICE->error)
MC/DC0%0/2
$Template::Config::SERVICE->new($params) || $class->error('failed to create context: ', $Template::Config::SERVICE->error)
$Template::Config::SERVICE->new($params)
$class->error('failed to create context: ', $Template::Config::SERVICE->error)
Truth table33%1/3
A || B
A= $Template::Config::SERVICE->new($params)B= $class->error('failed to create context: ', $Template::Config::SERVICE->error)
| |||||||||||||||||||||||||||||
| 257 | || $class->error( | ||||||||||||||||||||||||||||
| 258 | "failed to create context: ", | ||||||||||||||||||||||||||||
| 259 | $SERVICE->error | ||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 265 | # constants(\%params) | ||||||||||||||||||||||||||||
| 266 | # | ||||||||||||||||||||||||||||
| 267 | # Instantiate a new namespace handler for compile time constant folding | ||||||||||||||||||||||||||||
| 268 | # (default: Template::Namespace::Constants). | ||||||||||||||||||||||||||||
| 269 | # Returns object or undef, as above. | ||||||||||||||||||||||||||||
| 270 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 10 | ▶ | sub constants { | ||||||||||||||||||||||||||
|
Subroutine
constants: called CC=5 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||
| 273 | 10 | my $class = shift; | |||||||||||||||||||||||||||
| 274 | 10 | ▶ | my $params = defined($_[0]) && ref($_[0]) eq 'HASH' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and ref $_[0] eq "HASH"
MC/DC0%0/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0]
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 275 | ? shift | ||||||||||||||||||||||||||||
| 276 | : { @_ }; | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 10 | ▶ | return undef unless $class->load($CONSTANTS); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 10 | ▶ | return $CONSTANTS->new($params) | ||||||||||||||||||||||||||
|
Condition33%1/3
$Template::Config::CONSTANTS->new($params) || $class->error('failed to create constants namespace: ', $Template::Config::CONSTANTS->error)
MC/DC0%0/2
$Template::Config::CONSTANTS->new($params) || $class->error('failed to create constants namespace: ', $Template::Config::CONSTANTS->error)
$Template::Config::CONSTANTS->new($params)
$class->error('failed to create constants namespace: ', $Template::Config::CONSTANTS->error)
Truth table33%1/3
A || B
A= $Template::Config::CONSTANTS->new($params)B= $class->error('failed to create constants namespace: ', $Template::Config::CONSTANTS->error)
| |||||||||||||||||||||||||||||
| 280 | || $class->error( | ||||||||||||||||||||||||||||
| 281 | "failed to create constants namespace: ", | ||||||||||||||||||||||||||||
| 282 | $CONSTANTS->error | ||||||||||||||||||||||||||||
| 283 | ); | ||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 288 | # instdir($dir) | ||||||||||||||||||||||||||||
| 289 | # | ||||||||||||||||||||||||||||
| 290 | # Returns the root installation directory appended with any local | ||||||||||||||||||||||||||||
| 291 | # component directory passed as an argument. | ||||||||||||||||||||||||||||
| 292 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 6 | ▶ | sub instdir { | ||||||||||||||||||||||||||
|
Subroutine
instdir: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 295 | 6 | my ($class, $dir) = @_; | |||||||||||||||||||||||||||
| 296 | 6 | ▶ | my $inst = $INSTDIR | ||||||||||||||||||||||||||
|
Condition100%2/2
$Template::Config::INSTDIR || (return $class->error('no installation directory'))
MC/DC100%1/1
$Template::Config::INSTDIR || (return $class->error('no installation directory'))
$Template::Config::INSTDIR
Truth table100%2/2
A
A= $Template::Config::INSTDIR
| |||||||||||||||||||||||||||||
| 297 | || return $class->error("no installation directory"); | ||||||||||||||||||||||||||||
| 298 | 3 | ▶ | chop $inst while substr($inst,-1) eq '/'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 3 | ▶ | $inst .= "/$dir" if $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 3 | return $inst; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | #======================================================================== | ||||||||||||||||||||||||||||
| 305 | # This should probably be moved somewhere else in the long term, but for | ||||||||||||||||||||||||||||
| 306 | # now it ensures that Template::TieString is available even if the | ||||||||||||||||||||||||||||
| 307 | # Template::Directive module hasn't been loaded, as is the case when | ||||||||||||||||||||||||||||
| 308 | # using compiled templates and Template::Parser hasn't yet been loaded | ||||||||||||||||||||||||||||
| 309 | # on demand. | ||||||||||||||||||||||||||||
| 310 | #======================================================================== | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 313 | # simple package for tying $output variable to STDOUT, used by perl() | ||||||||||||||||||||||||||||
| 314 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | package Template::TieString; | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 15 | ▶ | sub TIEHANDLE { | ||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 319 | 15 | my ($class, $textref) = @_; | |||||||||||||||||||||||||||
| 320 | 15 | bless $textref, $class; | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | 7 | ▶ | sub PRINT { | ||||||||||||||||||||||||||
|
Subroutine
PRINT: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 323 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 324 | 7 | $$self .= join('', @_); | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | 3 | ▶ | sub PRINTF { | ||||||||||||||||||||||||||
|
Subroutine
PRINTF: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 327 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 328 | 3 | my $fmt = shift; | |||||||||||||||||||||||||||
| 329 | 3 | $$self .= sprintf($fmt, @_); | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 117 | 1; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | __END__ | ||||||||||||||||||||||||||||