Su/Template.pm

filter: Statementstmt 98.6% 371 / 376 Branchbran 63.3% 76 / 120 Conditioncond 40.7% 22 / 54 MC/DCmcdc 35.2% 12 / 34 Subroutinesub 100% 21 / 21 Podpod 23.8% 5 / 21 totaltotal 80.9% 507 / 626 CC 191 SCAR 29.1
CC
191
Cov
85%
expand
39.6
expand
39.5
make_template
16.9
CRAP 18.4
« Su/Model.pm ↑ Summary Su/Process.pm »
1 package Su::Template;
2  
3 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 39 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 41 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 38 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 37 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 40 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 41 ▶use Fatal qw(open close);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 39 ▶use Su::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 27 our @ISA = qw(Exporter);
16  
17 # render requires explicit use declaration.
18 27 our @EXPORT = qw(expand);
19 27 our @EXPORT_OK = qw(render);
20  
21 26 our $DEBUG = 0;
22  
23 # not used.
24 27 my $MODULE_PATH = __FILE__;
25  
26 # not used.
27 27 our $TEMPLATE_BASE_DIR = "./";
28  
29 # not used.
30 27 our $TEMPLATE_DIR = "Templates";
31  
32 =pod
33  
34 =head1 NAME
35  
36 Su::Template - A module to make the string using the specified template and passed parameters.
37  
38 =head1 SYNOPSIS
39  
40 my $tmpl = Su::Template->new;
41 my $str = $tmpl->expand( <<'HERE', $arg);
42 % my $arg = shift;
43 arg is <%=$arg%>
44 HERE
45  
46 =head1 DESCRIPTION
47  
48 Su::Template is a module to make the string using the specified template and passed parameters.
49  
50 =head1 AUTHOR
51  
52 lottz <lottzaddr@gmail.com>
53  
54 =head1 FUNCTIONS
55  
56 =over
57  
58 =cut
59  
60 =item new()
61  
62 A constructor.
63  
64 =cut
65  
66 17 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
67 23 my $self = shift;
68  
69 23 ▶ my %h = @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 16 16 32
70 22 my $log = Su::Log->new;
71 23 $h{logger} = $log;
72 22 return bless \%h, $self;
73 } ## end sub new
74  
75 74 ▶sub import {
Subroutine import: called CC=6 SCAR=18.8
76 80 my $self = shift;
77  
78 # Save import list and remove from hash.
79 80 ▶ my %tmp_h = @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 73 73
80 79 my $imports_aref = $tmp_h{import};
81 79 delete $tmp_h{import};
82 79 my $base = $tmp_h{base};
83 78 my $dir = $tmp_h{dir};
84 78 Su::Log->trace( "base:" . Dumper($base) );
85 78 Su::Log->trace( "dir:" . Dumper($dir) );
86  
87 # print "base:" . Dumper($base) . "\n";
88 # print "dir:" . Dumper($dir) . "\n";
89  
90 79 ▶ $TEMPLATE_BASE_DIR = $base if $base;
Branch: 1 branch
BranchTrueFalseTotal
if $base 14 76 90
91 79 ▶ $TEMPLATE_DIR = $dir if $dir;
Branch: 1 branch
BranchTrueFalseTotal
if $dir 0 76 76
92  
93 77 ▶ if ( $base || $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base or $dir) { } 7 74 81
Condition16%1/6
$base or $dir
l!l&&r!l&&!r
0073
$base or $dir
l!l&&r!l&&!r
000
MC/DC0%0/2
$base or $dir
$base $dir
MC/DC0%0/2
$base or $dir
$base $dir
Truth table33%1/3
A or B
A= $baseB= $dir
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $baseB= $dir
ABresult
1X1
011
000
94 5 $self->export_to_level( 1, $self, @{$imports_aref} );
95 } else {
96  
97 # If 'base' or 'dir' is not passed, then all of the parameters are required method names.
98 76 $self->export_to_level( 1, $self, @_ );
99 }
100  
101 } ## end sub import
102  
103 =item expand()
104  
105 Expand the template using the passed context and return the result string.
106 Note that the keyword for here document must quoted by single quote. Double quote should cause unexpected error.
107  
108 Template syntax:
109  
110 <%= $val %> render the variable. Html special character will escaped.
111 <%== $val %> render the variable. Html special character will not escaped.
112 End tag ~%> discards line separator.
113 Expression surrounded by <% %> or the line start with '%' will parsed as Perl statements.
114  
115 If you want debug output, set the following flag on, then expand method return the debug string.
116  
117 $Su::Template::DEBUG=1;
118  
119 The functional style usage of this method is the following.
120  
121 $ret = Su::Template::expand(<<'__HERE__');
122 <% foreach my $v ("aa","bb","cc"){~%>
123 <%= $v%>
124 <%}~%>
125 xxx
126 yyy
127 zzz
128 __HERE__
129  
130 The OO style usage of this method is the following.
131  
132 my $tmpl = Su::Template->new;
133 my $str = $tmpl->expand( <<'HERE', $title, $link );
134 % my $title = shift;
135 % my $link = shift;
136 <a href="<%=$link%>"><%=$title%></a>
137 HERE
138  
139 The html special character in variable expression will be escaped like the following.
140  
141 $ret = $t->expand( <<'__HERE__', "aa<bb>cc'dd\"ee&ff" );
142 % my $arg = shift;
143 <%= $arg ~%>
144 __HERE__
145  
146 is( $ret, "aa&lt;bb&gt;cc&apos;dd&quot;ee&amp;ff" );
147  
148 Note that the html special character described in the raw part of the template will not be escaped.
149  
150 =cut
151  
152 27 my $escape_hash_str =
153 "my %escape_h = ( '<' => '&lt;', '>' => '&gt;', '\"' => '&quot;', \"'\", => '&apos;', '&' => '&amp;',);";
154  
155 61 ▶sub expand {
Subroutine expand: called CC=35 SCAR=36.8
Pod documented
156 32 ▶ no warnings qw(redefine);
Subroutine BEGIN: called CC=1 SCAR=0.0
157  
158 # TODO: If the pushed data to the list @f_t_a is a empty strng, then
159 # we should remove this process to simplify and optimize the
160 # method `make_template`. But whether add "\n" or not is rather
161 # complex, so optimization is a put-offed task.
162 64 ▶ my $self = shift if ( ref $_[0] eq __PACKAGE__ );
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq __PACKAGE__ 32 28 60
163 64 ▶ my $DEBUG = $self->{debug} ? $self->{debug} : $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'debug'} ? : 4 60 64
164  
165 62 my $org = shift;
166 63 my @args = @_;
167 63 my @ret = "";
168 63 my $b_perl_mode = 0;
169 63 my $b_no_last_newline = 0;
170 63 my $b_need_escape_hash = 0;
171 66 my $b_need_tmp_val = 0;
172  
173 # add dumy \n prepare for after pop. And set flag not to add \n the end of the line.
174 66 ▶ if ( substr( $org, ( length $org ) - 1 ) ne "\n" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($org, length($org) - 1) ne "\n") 10 50 60
175 16 $org .= "\n";
176 16 $b_no_last_newline = 1;
177 }
178  
179 66 my @lines = split "\n", $org, -1;
180 66 pop @lines;
181 66 my $line_num = scalar @lines;
182 63 my $current_line = 0;
183 66 my $candidate_str = '';
184 65 Su::Log->trace( "org:" . Dumper($org) );
185 66 for my $l (@lines) {
186 1056 Su::Log->trace( "loop:" . $l );
187 1056 ++$current_line;
188 1056 my $b_match = 0;
189 1053 my $b_need_line_return = 1;
190 1056 ▶ if ( $b_perl_mode && $l =~ /(.*)%>(\s*)$/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($b_perl_mode and $l =~ /(.*)%>(\s*)$/) { } 3 1048 1051
elsif ($b_perl_mode) { } 3 1045 1048
elsif (substr($l, 0, 1) eq '%') { } 148 898 1046
elsif ($l =~ /^\s*<%(.*)/ and index($l, '%>') == -1) { } 5 896 901
Condition50%3/6
$b_perl_mode and $l =~ /(.*)%>(\s*)$/
!ll&&!rl&&r
104532
$b_perl_mode and $l =~ /(.*)%>(\s*)$/
!ll&&!rl&&r
000
MC/DC100%2/2
$b_perl_mode and $l =~ /(.*)%>(\s*)$/
$b_perl_mode $l =~ /(.*)%>(\s*)$/
MC/DC0%0/2
$b_perl_mode and $l =~ /(.*)%>(\s*)$/
$b_perl_mode $l =~ /(.*)%>(\s*)$/
Truth table100%3/3
A and B
A= $b_perl_modeB= $l =~ /(.*)%>(\s*)$/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $b_perl_modeB= $l =~ /(.*)%>(\s*)$/
ABresult
0X0
100
111
191 8 $b_perl_mode = 0;
192 8 $b_match = 1;
193 8 $b_need_line_return = 0;
194 8 push @ret, $1;
195 8 Su::Log->trace("perl mode out");
196 } elsif ($b_perl_mode) {
197 9 Su::Log->trace("is perl mode");
198 9 $b_match = 1;
199 9 $b_need_line_return = 0;
200 9 push @ret, $l;
201 } elsif ( substr( $l, 0, 1 ) eq '%' ) {
202 152 push @ret, substr( $l, 1 );
203 153 $b_match = 1;
204 153 $b_need_line_return = 0;
205 ▶ } elsif ( $l =~ /^\s*<%(.*)/ && index( $l, "%>" ) == -1 ) {
Condition50%3/6
$l =~ /^\s*<%(.*)/ and index($l, "%>") == -1
!ll&&!rl&&r
842542
$l =~ /^\s*<%(.*)/ and index($l, "%>") == -1
!ll&&!rl&&r
000
MC/DC100%2/2
$l =~ /^\s*<%(.*)/ and index($l, "%>") == -1
$l =~ /^\s*<%(.*)/ index($l, "%>") == -1
MC/DC0%0/2
$l =~ /^\s*<%(.*)/ and index($l, "%>") == -1
$l =~ /^\s*<%(.*)/ index($l, "%>") == -1
Truth table100%3/3
A and B
A= $l =~ /^\s*<%(.*)/B= index($l, "%>") == -1
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $l =~ /^\s*<%(.*)/B= index($l, "%>") == -1
ABresult
0X0
100
111
206 8 $b_perl_mode = 1;
207 8 $b_need_line_return = 0;
208 8 $b_match = 1;
209 8 push @ret, $1;
210 8 Su::Log->trace("perl mode in");
211 } else {
212 903 my $prev_pos = 0;
213 903 ▶ while ( $l =~ /<%((={0,2})(.*?)([~])?)%>/g ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /<%((={0,2})(.*?)([~])?)%>/g) 145 896 1041
214 149 $b_match = 1;
215  
216 # push @ret, ('push(@f_t_a, \'' . $`. '\');') if $`; # add previous part
217 149 my $tmp = $-[0];
218  
219 150 $candidate_str = substr( $l, $prev_pos, $tmp - $prev_pos );
220  
221 #note: Ensure matched varibe like $1 not effect outer scope.
222 {
223 150 ▶ $candidate_str =~ s/'/\\'/g if defined $candidate_str;
Branch: 1 branch
BranchTrueFalseTotal
if defined $candidate_str 147 0 147
224 }
225 150 ▶ $candidate_str && push @ret,
Branch: 1 branch
BranchTrueFalseTotal
$candidate_str and push @ret, q[push(@f_t_a, '] . $candidate_str . q[');] 128 17 145
226 ( 'push(@f_t_a, \'' . $candidate_str . '\');' )
227 ; # save from previous end pos to current start pos.
228 152 ▶ if ( defined $2 && ( $2 eq '=' or $2 eq '==' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $2 and $2 eq '=' || $2 eq '==') { } 146 4 150
Condition41%5/12
defined $2 and $2 eq "=" || $2 eq "=="
!ll&&!rl&&r
04140
$2 eq "=" or $2 eq "=="
l!l&&r!l&&!r
13734
defined $2 and $2 eq "=" || $2 eq "=="
!ll&&!rl&&r
000
$2 eq "=" or $2 eq "=="
l!l&&r!l&&!r
000
MC/DC66%2/3
defined $2 and $2 eq "=" || $2 eq "=="
defined $2 $2 eq "=" $2 eq "=="
MC/DC0%0/3
defined $2 and $2 eq "=" || $2 eq "=="
defined $2 $2 eq "=" $2 eq "=="
Truth table75%3/4
A and B or C
A= defined $2B= $2 eq "="C= $2 eq "=="
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/4
A and B or C
A= defined $2B= $2 eq "="C= $2 eq "=="
ABCresult
0XX0
1000
11X1
1011
229 { # print variable itself
230 148 my $exp = $3;
231  
232 148 $b_need_tmp_val = 1;
233 148 ▶ if ( $2 eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 eq "=") 137 4 141
234 145 $b_need_escape_hash = 1;
235 }
236  
237 {
238 148 $exp =~ s/^ *(.*?) *$/$1/; # trim front and end of white space.
239 }
240  
241 # push @ret, ('push(@f_t_a, (' . $exp . '));'); # NOTE: other variables may be double quote not single quote like this like.
242  
243 # Escape and push.
244 147 ▶ if ( $2 eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 eq '=') { } 141 4 145
245 142 push @ret, '$tmp_val = ' . '(' . $exp . ');';
246  
247 # If the special charactor is already escaped using '&', then prevent unexpected double escaped.
248 142 push @ret, 'if($tmp_val){
249 $tmp_val=~s/&(?!(lt|gt|amp|quot|apos);)/&amp;/go;
250 $tmp_val=~s/(<|>|\'|")/$escape_h{$1}/go;';
251  
252 # $tmp_val=~s/(<|>|\'|"|&)/$escape_h{$1}/go;';
253 143 push @ret, ( 'push(@f_t_a, $tmp_val' . ');}' );
254 142 push @ret, ('elsif(defined $tmp_val){push(@f_t_a, $tmp_val);}');
255 } else {
256  
257 # Push only. Not escape.
258 8 push @ret, '$tmp_val = ' . '(' . $exp . ');';
259 7 push @ret, 'if($tmp_val){';
260 7 push @ret, ( 'push(@f_t_a, $tmp_val' . ');}' );
261 5 push @ret, ('elsif(defined $tmp_val){push(@f_t_a, $tmp_val);}');
262  
263 } ## end else [ if ( $2 eq '=' ) ]
264  
265 } else {
266 8 push @ret, $3;
267 }
268 148 $prev_pos = pos($l);
269  
270 149 ▶ $b_need_line_return = 0 if ( defined $4 && $4 eq '~' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $4 and $4 eq "~" 25 121 146
Condition33%2/6
defined $4 and $4 eq "~"
!ll&&!rl&&r
119025
defined $4 and $4 eq "~"
!ll&&!rl&&r
000
MC/DC50%1/2
defined $4 and $4 eq "~"
defined $4 $4 eq "~"
MC/DC0%0/2
defined $4 and $4 eq "~"
defined $4 $4 eq "~"
Truth table66%2/3
A and B
A= defined $4B= $4 eq "~"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $4B= $4 eq "~"
ABresult
0X0
100
111
271 } #while match
272  
273 # If match, register tail part. If not this condition, <% %>not include line will retisterred twice!
274 900 ▶ if ($b_match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b_match) 121 778 899
275 122 $candidate_str = substr( $l, $prev_pos, ( length $l ) - $prev_pos );
276  
277 #note: Ensure matched varibe like $1 not effect outer scope.
278 {
279 120 ▶ $candidate_str =~ s/'/\\'/g if defined $candidate_str;
Branch: 1 branch
BranchTrueFalseTotal
if defined $candidate_str 118 1 119
280 }
281 120 ▶ $candidate_str && push @ret,
Branch: 1 branch
BranchTrueFalseTotal
$candidate_str and push @ret, q[push(@f_t_a, '] . $candidate_str . q[');] 69 51 120
282 ( 'push(@f_t_a, \'' . $candidate_str . '\');' )
283 ; # save to the tail of the line.
284 } ## end if ($b_match)
285 } # else end
286  
287 1053 ▶ my $no_need_newline = ( $line_num == $current_line ) && $b_no_last_newline;
Condition50%3/6
$line_num == $current_line && $b_no_last_newline
!ll&&!rl&&r
9905010
$line_num == $current_line && $b_no_last_newline
!ll&&!rl&&r
000
MC/DC100%2/2
$line_num == $current_line && $b_no_last_newline
$line_num == $current_line $b_no_last_newline
MC/DC0%0/2
$line_num == $current_line && $b_no_last_newline
$line_num == $current_line $b_no_last_newline
Truth table100%3/3
A && B
A= $line_num == $current_lineB= $b_no_last_newline
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= $line_num == $current_lineB= $b_no_last_newline
ABresult
0X0
100
111
288  
289 # Add new line to the make_template function itself. If the current line is comment, then we need new line to add \n to the @f_t_a array.
290 1053 push @ret, "\n";
291  
292 1052 ▶ if ($b_match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b_match) { } 272 779 1051
293 274 Su::Log->trace("line b_match");
294  
295 # push @ret, ('push(@f_t_a, \'' . (($b_need_line_return && !$b_no_newline) ? "\n" : '') . '\');');# print eol.
296 274 ▶ push @ret,
Branch: 1 branch
BranchTrueFalseTotal
$b_need_line_return && !$no_need_newline ? : 90 184 274
Condition50%3/6
$b_need_line_return and not $no_need_newline
!ll&&!rl&&r
179588
$b_need_line_return and not $no_need_newline
!ll&&!rl&&r
000
MC/DC100%2/2
$b_need_line_return and not $no_need_newline
$b_need_line_return not $no_need_newline
MC/DC0%0/2
$b_need_line_return and not $no_need_newline
$b_need_line_return not $no_need_newline
Truth table100%3/3
A and not(B)
A= $b_need_line_returnB= not $no_need_newline
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $b_need_line_returnB= not $no_need_newline
ABresult
0X0
100
111
297 ( 'push(@f_t_a, \''
298 . ( ( $b_need_line_return && !$no_need_newline ) ? "\n" : '' )
299 . '\');' ); # print eol.
300 } else {
301 779 Su::Log->trace("line not b_match");
302 780 $l =~ s/'/\\'/g;
303  
304 # push @ret, ('push(@f_t_a, \'' . $l. (($b_need_line_return && !$b_no_newline) ? "\n" : '') . '\');');#print whole line.
305 780 ▶ if ( !$b_need_line_return || $no_need_newline ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $b_need_line_return or $no_need_newline) { } 5 773 778
Condition33%2/6
not $b_need_line_return or $no_need_newline
l!l&&r!l&&!r
05773
not $b_need_line_return or $no_need_newline
l!l&&r!l&&!r
000
MC/DC50%1/2
not $b_need_line_return or $no_need_newline
not $b_need_line_return $no_need_newline
MC/DC0%0/2
not $b_need_line_return or $no_need_newline
not $b_need_line_return $no_need_newline
Truth table66%2/3
not(A) or B
A= not $b_need_line_returnB= $no_need_newline
ABresult
1X1
011
000
Truth table0%0/3
not(A) or B
A= not $b_need_line_returnB= $no_need_newline
ABresult
1X1
011
000
306 7 ▶ $l && push @ret, ( 'push(@f_t_a, \'' . $l . '\');' );
Branch: 1 branch
BranchTrueFalseTotal
$l and push @ret, q[push(@f_t_a, '] . $l . q[');] 5 0 5
307 } else {
308  
309 #print whole line.
310 775 push @ret, ( 'push(@f_t_a, \'' . $l . "\n" . '\');' );
311 }
312 } ## end else [ if ($b_match) ]
313  
314 # push @ret, "\n";
315 } #while line
316  
317 61 ▶ unshift( @ret, 'my $tmp_val="";' . "\n" )
Branch: 1 branch
BranchTrueFalseTotal
if $b_need_tmp_val 50 11 61
318 if $b_need_tmp_val;
319 62 ▶ unshift( @ret, $escape_hash_str . "\n" )
Branch: 1 branch
BranchTrueFalseTotal
if $b_need_escape_hash 46 14 60
320 if $b_need_escape_hash;
321  
322 62 unshift( @ret, 'sub make_template{' . "\n" . 'my @f_t_a=();' . "\n" );
323 62 push( @ret, 'return join(\'\',@f_t_a);' . "\n" . '}' );
324 62 my $prepare_data = join( '', @ret );
325 0 ▶ eval($prepare_data);
Subroutine make_template: called CC=16 SCAR=28.3
Subroutine make_template: called CC=3 SCAR=11.1
Subroutine make_template: called CC=16 SCAR=28.3
Subroutine make_template: called CC=11 SCAR=24.4
Subroutine make_template: called CC=3 SCAR=11.1
Subroutine make_template: called CC=16 SCAR=28.3
Subroutine make_template: called CC=3 SCAR=11.1
Pod documented
Pod documented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 30 branches
BranchTrueFalseTotal
if ($tmp_val) { } 25 0 25
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 16 6 22
elsif (defined $tmp_val) { } 0 4 4
if (() = each %{$href;}) 6 0 6
if (ref $v eq 'HASH') { } 0 0 0
if ($tmp_val) { } 4 0 4
elsif (defined $tmp_val) { } 0 0 0
if (() = each %{$v;}) 4 0 4
if ($tmp_val) { } 0 0 0
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 4 0 4
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 4 0 4
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 4 0 4
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 4 2 6
elsif (defined $tmp_val) { } 1 1 2
if (() = each %{$href;}) 2 0 2
if (ref $v eq 'HASH') { } 0 0 0
if ($tmp_val) { } 2 1 3
elsif (defined $tmp_val) { } 2 0 2
if (() = each %{$v;}) 0 0 0
if ($tmp_val) { } 2 0 2
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 1 0 1
elsif (defined $tmp_val) { } 0 0 0
if ($tmp_val) { } 1 0 1
elsif (defined $tmp_val) { } 0 0 0
326 62 ▶ $@ and die "[ERROR]Invalid Template format:" . $@ . "\n" . $prepare_data;
Branch: 1 branch
BranchTrueFalseTotal
$@ and die '[ERROR]Invalid Template format:' . $@ . "\n" . $prepare_data 1 60 61
327  
328 62 ▶ if ($DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DEBUG) { } 0 60 60
329 1 return $prepare_data; # return pre-eval data.
330 } else {
331 61 return make_template(@args); # call evaled method.
332 }
333 } # eos expand()
334  
335 =item render()
336  
337 An alias to the method L<expand>.
338  
339 =cut
340  
341 1 ▶sub render {
Subroutine render: called CC=1 SCAR=0.0
Pod documented
342 1 return expand(@_);
343 }
344  
345 =pod
346  
347 =back
348  
349 =cut
350  
351 27 1;
352  
« Su/Model.pm ↑ Summary Su/Process.pm »