Branch Coverage

blib/lib/HTML/Template.pm
Criterion Covered Total %
branch 532 704 75.5


line true false branch
1122 2 303 if $$options{'blind_cache'}
1125 0 305 if $$options{'shared_cache'}
1128 15 290 if $$options{'file_cache'}
1131 1 304 if $$options{'double_cache'}
1132 1 304 if $$options{'double_cache'}
1135 3 302 if $$options{'double_file_cache'}
1136 3 302 if $$options{'double_file_cache'}
1139 1 304 if $$options{'vanguard_compatibility_mode'}
1143 10 295 if (exists $$options{'type'})
1144 1 9 unless exists $$options{'source'}
1147 1 4 unless $$options{'type'} eq 'filename' or $$options{'type'} eq 'scalarref' or $$options{'type'} eq 'arrayref' or $$options{'type'} eq 'filehandle'
1160 2 301 if ($$options{'force_untaint'})
1161 0 2 if ($] < 5.008) { }
1 1 elsif (not ${^TAINT}) { }
1170 3 299 if (ref $$options{'associate'} ne 'ARRAY')
1175 73 229 if (ref $$options{'path'} ne 'ARRAY')
1180 4 298 if (ref $$options{'filter'} ne 'ARRAY')
1186 1 2 unless defined $object->can('param')
1194 115 186 if exists $$options{'filename'}
1195 5 296 if exists $$options{'filehandle'}
1196 3 298 if exists $$options{'arrayref'}
1197 177 124 if exists $$options{'scalarref'}
1198 1 300 if ($source_count != 1)
1207 3 297 if grep {exists $$options{$_};} 'filehandle', 'arrayref', 'scalarref' and grep {$$options{$_};} 'cache', 'blind_cache', 'file_cache', 'shared_cache', 'double_cache', 'double_file_cache'
1212 115 182 if (exists $$options{'filename'})
1213 1 114 unless length $$options{'filename'}
1218 0 296 if ($$options{'memory_debug'})
1221 0 0 if $@
1228 17 279 if ($$options{'file_cache'})
1230 1 16 unless length $$options{'file_cache_dir'}
1235 0 16 if $@
1240 0 295 if ($$options{'shared_cache'})
1243 0 0 if $@
1260 122 173 if ($$options{'default_escape'})
1262 1 121 unless ($$options{'default_escape'} =~ /^(NONE|HTML|URL|JS)$/i)
1270 0 294 if ($$options{'open_mode'} and $] < 5.007001)
1274 6 288 if ($$options{'utf8'})
1275 0 6 if $] < 5.007001
1276 1 5 if $$options{'open_mode'}
1282 0 293 if $$options{'memory_debug'}
1288 0 281 if $$options{'memory_debug'}
1295 0 281 if $$options{'shared_cache'}
1304 4 1399 unless defined ${$argsref;}[$x + 1]
1363 0 293 if ($$options{'double_cache'}) { }
3 290 elsif ($$options{'double_file_cache'}) { }
0 290 elsif ($$options{'shared_cache'}) { }
13 277 elsif ($$options{'file_cache'}) { }
11 266 elsif ($$options{'cache'}) { }
1366 0 0 if defined $$self{'param_map'} and defined $$self{'parse_stack'}
1372 0 0 if defined $$self{'param_map'} and defined $$self{'parse_stack'}
1377 2 1 if defined $$self{'param_map'}
1383 0 1 if defined $$self{'param_map'}
1397 9 282 if defined $$self{'param_map'}
1406 10 260 if ($$options{'file_cache'})
1410 7 263 if $$options{'cache'} and not $$options{'shared_cache'} and not $$options{'file_cache'} or $$options{'double_cache'} or $$options{'double_file_cache'}
1427 0 14 unless defined $filepath
1432 7 7 unless exists $HTML::Template::CACHE{$key}
1436 6 1 if (defined $mtime)
1438 0 6 if (defined $HTML::Template::CACHE{$key}{'mtime'} and $mtime != $HTML::Template::CACHE{$key}{'mtime'})
1441 0 0 if $$options{'cache_debug'}
1448 1 5 if (exists $HTML::Template::CACHE{$key}{'included_mtimes'})
1451 0 2 unless defined $HTML::Template::CACHE{$key}{'included_mtimes'}{$filename}
1454 0 2 if ($included_mtime != $HTML::Template::CACHE{$key}{'included_mtimes'}{$filename})
1455 0 0 if $$options{'cache_debug'}
1467 1 6 if $$options{'cache_debug'}
1472 1 6 if exists $HTML::Template::CACHE{$key}{'included_mtimes'}
1486 1 6 if $$options{'cache_debug'}
1489 6 1 unless $$options{'blind_cache'}
1493 3 4 if exists $$self{'included_mtimes'}
1530 10 14 if (wantarray) { }
1544 0 14 unless defined $filepath
1546 10 4 unless -e $cache_filename
1549 0 4 if $@
1551 0 4 unless defined $$self{'record'}
1560 4 0 if (defined $mtime)
1562 0 4 if (defined $$self{'mtime'} and $mtime != $$self{'mtime'})
1565 0 0 if $$options{'cache_debug'}
1573 4 0 if (exists $$self{'included_mtimes'})
1576 0 0 unless defined $$self{'included_mtimes'}{$filename}
1579 0 0 if ($included_mtime != $$self{'included_mtimes'}{$filename})
1580 0 0 if $$options{'cache_debug'}
1592 1 3 if $$options{'cache_debug'}
1605 0 10 unless (defined $filepath)
1607 0 0 unless defined $filepath
1614 10 0 unless (-d $cache_dir)
1615 0 10 unless (-d $$options{'file_cache_dir'})
1616 0 0 unless mkdir $$options{'file_cache_dir'}, $$options{'file_cache_dir_mode'}
1619 0 10 unless mkdir $cache_dir, $$options{'file_cache_dir_mode'}
1623 1 9 if $$options{'cache_debug'}
1631 0 10 if $@
1632 0 10 unless defined $result
1642 0 0 unless defined $filepath
1647 0 0 if defined $$self{'record'}
1650 0 0 if $$options{'cache_debug'} and defined $$self{'record'}
1654 0 0 if defined $$self{'record'}
1665 0 0 if $$options{'shared_cache_debug'}
1668 0 0 if $$options{'blind_cache'}
1674 0 0 if (defined $mtime and defined $c_mtime and $mtime != $c_mtime)
1678 0 0 if $$options{'cache_debug'}
1685 0 0 if (defined $mtime and defined $included_mtimes)
1687 0 0 unless defined $$included_mtimes{$fname}
1688 0 0 if ($$included_mtimes{$fname} != (stat $fname)[9])
1689 0 0 if $$options{'cache_debug'}
1708 0 0 if $$options{'cache_debug'}
1711 0 0 if $$options{'memory_debug'}
1725 4 181 if 'File::Spec'->file_name_is_absolute($filename) and -e $filename
1729 65 116 if (defined $extra_path)
1732 41 24 if -e $filepath
1736 4 136 if (defined $ENV{'HTML_TEMPLATE_ROOT'})
1738 1 3 if -e $filepath
1744 111 8 if -e $filepath
1748 20 8 if -e $filename
1751 3 5 if (defined $ENV{'HTML_TEMPLATE_ROOT'})
1754 1 1 if -e $filepath
1766 2 112 if $$options{'blind_cache'}
1769 0 112 unless -r $filepath
1786 27 0 unless ref $item eq 'HTML::Template::LOOP'
1806 0 282 if $$options{'memory_debug'}
1809 100 182 if (exists $$options{'filename'}) { }
176 6 elsif (exists $$options{'scalarref'}) { }
2 4 elsif (exists $$options{'arrayref'}) { }
4 0 elsif (exists $$options{'filehandle'}) { }
1811 84 16 unless (defined $filepath)
1813 3 81 unless defined $filepath
1820 6 91 if (my $mode = $$options{'open_mode'}) { }
1821 0 6 unless open TEMPLATE, $mode, $filepath
1824 0 91 unless open TEMPLATE, $filepath
1855 0 279 if $$options{'memory_debug'}
1859 5 274 if @{$$options{'filter'};}
1872 0 11 unless ref $filter
1876 2 9 if ref $filter eq 'CODE'
1879 11 0 if (ref $filter eq 'HASH') { }
1884 0 11 unless defined $format and defined $sub
1887 0 11 unless $format eq 'array' or $format eq 'scalar'
1890 0 11 unless ref $sub and ref $sub eq 'CODE'
1895 8 3 if ($format eq 'scalar') { }
1908 0 11 if $@
1926 0 279 if $$options{'debug'}
1990 1 278 if $$options{'vanguard_compatibility_mode'}
2002 0 1541 unless defined $chunks[$chunk_number]
2006 750 791 if ($chunk =~ m[^< (?:!--\s*)? ( /?tmpl_ (?: (?:var) | (?:loop) | (?:if) | (?:else) | (?:unless) | (?:include) ) ) # $1 => $which - start of the tag \s* # DEFAULT attribute (?: default \s*=\s* (?: "([^">]*)" # $2 => double-quoted DEFAULT value " | '([^'>]*)' # $3 => single-quoted DEFAULT value | ([^\s=>]*) # $4 => unquoted DEFAULT value ) )? \s* # ESCAPE attribute (?: escape \s*=\s* (?: ( (?:["']?0["']?)| (?:["']?1["']?)| (?:["']?html["']?) | (?:["']?url["']?) | (?:["']?js["']?) | (?:["']?none["']?) ) # $5 => ESCAPE on ) )* # allow multiple ESCAPEs \s* # DEFAULT attribute (?: default \s*=\s* (?: "([^">]*)" # $6 => double-quoted DEFAULT value " | '([^'>]*)' # $7 => single-quoted DEFAULT value | ([^\s=>]*) # $8 => unquoted DEFAULT value ) )? \s* # NAME attribute (?: (?: name \s*=\s*)? (?: "([^">]*)" # $9 => double-quoted NAME value " | '([^'>]*)' # $10 => single-quoted NAME value | ([^\s=>]*) # $11 => unquoted NAME value ) )? \s* # DEFAULT attribute (?: default \s*=\s* (?: "([^">]*)" # $12 => double-quoted DEFAULT value " | '([^'>]*)' # $13 => single-quoted DEFAULT value | ([^\s=>]*) # $14 => unquoted DEFAULT value ) )? \s* # ESCAPE attribute (?: escape \s*=\s* (?: ( (?:["']?0["']?)| (?:["']?1["']?)| (?:["']?html["']?) | (?:["']?url["']?) | (?:["']?js["']?) | (?:["']?none["']?) ) # $15 => ESCAPE on ) )* # allow multiple ESCAPEs \s* # DEFAULT attribute (?: default \s*=\s* (?: "([^">]*)" # $16 => double-quoted DEFAULT value " | '([^'>]*)' # $17 => single-quoted DEFAULT value | ([^\s=>]*) # $18 => unquoted DEFAULT value ) )? \s* (?:--)?/?> (.*) # $19 => $post - text that comes after the tag $]six) { }
2124 30 569 defined $$options{'default_escape'} && $which eq 'TMPL_VAR' ? :
94 599 defined $15 ? :
57 693 defined $5 ? :
2132 598 0 defined $11 ? :
18 598 defined $10 ? :
134 616 defined $9 ? :
2135 4 706 defined $18 ? :
0 710 defined $17 ? :
6 710 defined $16 ? :
16 716 defined $14 ? :
1 732 defined $13 ? :
9 733 defined $12 ? :
0 742 defined $8 ? :
0 742 defined $7 ? :
3 742 defined $6 ? :
5 745 defined $4 ? :
0 750 defined $3 ? :
0 750 defined $2 ? :
2153 670 80 unless not defined $name or $which eq 'TMPL_INCLUDE' or $$options{'case_sensitive'}
2157 1 749 if $need_names{$which} and not defined $name && length $name
2161 1 748 if $escape and $which ne 'TMPL_VAR'
2165 1 747 if defined $default and $which ne 'TMPL_VAR'
2169 363 384 if ($which eq 'TMPL_VAR') { }
86 298 elsif ($which eq 'TMPL_LOOP') { }
86 212 elsif ($which eq '/TMPL_LOOP') { }
55 157 elsif ($which eq 'TMPL_IF' or $which eq 'TMPL_UNLESS') { }
54 103 elsif ($which eq '/TMPL_IF' or $which eq '/TMPL_UNLESS') { }
29 74 elsif ($which eq 'TMPL_ELSE') { }
74 0 elsif ($which eq 'TMPL_INCLUDE') { }
2170 0 363 if $$options{'debug'}
2175 32 331 if (exists $HTML::Template::pmap{$name}) { }
2177 0 32 if ($$options{'die_on_bad_params'} and ref $var ne 'HTML::Template::VAR')
2183 7 324 if $$options{'global_vars'} and not exists $HTML::Template::top_pmap{$name}
2189 43 320 if (defined $default)
2196 171 192 if ($escape)
2197 39 132 if ($escape =~ /^["']?url["']?$/i) { }
27 105 elsif ($escape =~ /^["']?js["']?$/i) { }
16 89 elsif ($escape =~ /^["']?0["']?$/) { }
25 64 elsif ($escape =~ /^["']?none["']?$/i) { }
2214 0 86 if $$options{'debug'}
2219 14 72 if (exists $HTML::Template::pmap{$name}) { }
2221 0 14 if ($$options{'die_on_bad_params'} and ref $loop ne 'HTML::Template::LOOP')
2251 14 72 if ($$options{'loop_context_vars'})
2263 0 86 if $$options{'debug'}
2267 0 86 unless defined $loopdata
2275 11 4 if (exists $HTML::Template::pmap{$var}) { }
2279 1 3 if $$options{'global_vars'} and not exists $HTML::Template::top_pmap{$var}
2283 15 0 if (ref $HTML::Template::pmap{$var} eq 'HTML::Template::VAR') { }
2297 0 86 if scalar @HTML::Template::ifstack
2323 67 19 if ($$options{'die_on_bad_params'})
2326 14 53 if (@loop_keys > 1)
2331 26 14 if $$loops{$loop}{'param_map'}{$param}
2336 40 8 if $$loops{$last_loop}{'param_map'}{$param}
2344 0 55 if $$options{'debug'}
2350 13 42 if (exists $HTML::Template::pmap{$name}) { }
2358 46 9 if ($which eq 'TMPL_IF') { }
2368 42 13 if ($var eq $name) { }
2371 13 0 if (ref $var eq 'HTML::Template::VAR') { }
2383 0 54 if $$options{'debug'}
2387 0 54 unless defined $cond
2389 45 9 if ($which eq '/TMPL_IF') { }
2390 0 45 if $$cond[4] == 1
2394 0 9 if $$cond[4] == 0
2406 0 29 if $$options{'debug'}
2410 0 29 unless defined $cond
2413 1 28 if $$cond[6]
2423 8 20 if (defined $$cond[1]) { }
2441 0 74 if $$options{'debug'}
2445 1 73 if $$options{'no_includes'}
2452 6 67 if ($$options{'search_path_on_include'}) { }
2457 2 71 if not defined $filepath and $$options{'die_on_missing_include'}
2461 69 2 if ($filepath)
2463 0 69 if (my $mode = $$options{'open_mode'}) { }
2464 0 0 unless open TEMPLATE, $mode, $filepath
2467 0 69 unless open TEMPLATE, $filepath
2477 4 67 if @{$$options{'filter'};}
2479 69 2 if ($included_template)
2482 1 68 if $$options{'vanguard_compatibility_mode'}
2486 6 63 if ($$options{'cache'} and not $$options{'blind_cache'})
2495 1 68 if $$options{'max_includes'} and scalar @fstack > $$options{'max_includes'}
2522 674 0 if (defined $post)
2523 2 672 if (ref $HTML::Template::pstack[$#HTML::Template::pstack] eq 'SCALAR') { }
2531 786 5 if ($$options{'strict'})
2532 1 785 if $chunk =~ m[<(?:!--\s*)?/?tmpl_]i
2537 790 0 if (defined $chunk)
2538 688 102 if (ref $HTML::Template::pstack[$#HTML::Template::pstack] eq 'SCALAR') { }
2549 28 1436 if $HTML::Template::fcounter > $HTML::Template::fmax
2555 0 270 if scalar @HTML::Template::ifstack
2557 0 270 if scalar @loopstack
2563 33 12 if (exists $HTML::Template::pmap{$var}) { }
2567 0 12 if $$options{'global_vars'} and not exists $HTML::Template::top_pmap{$var}
2571 23 22 if (ref $HTML::Template::pmap{$var} eq 'HTML::Template::VAR') { }
2579 0 270 if ($$options{'stack_debug'})
2642 1 3 if ($opt eq 'associate' or $opt eq 'filter' or $opt eq 'path') { }
2719 45 566 unless scalar @_
2726 121 159 unless (scalar @_ or length $type)
2727 2 119 $$options{'case_sensitive'} ? :
2730 1 120 if $$options{'die_on_bad_params'} and not exists $$param_map{$param}
2736 2 118 unless exists $$param_map{$param} and defined $$param_map{$param}
2739 107 11 if ref $$param_map{$param} eq 'HTML::Template::VAR'
2744 159 286 if (not scalar @_) { }
2745 2 157 unless $type eq 'HASH' or UNIVERSAL::isa($first, 'HASH')
2753 1 442 unless @_ % 2 == 0
2760 5 995 $$options{'case_sensitive'} ? :
2764 0 1000 if $$options{'die_on_bad_params'} and not exists $$param_map{$param}
2772 45 955 unless (exists $$param_map{$param})
2773 41 4 unless $$options{'parent_global_vars'}
2777 1 3 if (ref $value eq 'ARRAY') { }
2787 1 958 if ($type eq 'REF') { }
50 908 elsif ($type and $type eq 'ARRAY' || !($type =~ /^(CODE)|(HASH)|(SCALAR)$/) && $value->isa('ARRAY')) { }
30 878 elsif ($type eq 'CODE') { }
2790 0 50 unless ref $$param_map{$param} eq 'HTML::Template::LOOP'
2796 11 19 if (ref $$param_map{$param} eq 'HTML::Template::LOOP') { }
2802 0 878 unless ref $$param_map{$param} eq 'HTML::Template::VAR'
2821 710 13 if $type eq 'HTML::Template::VAR'
2823 13 710 if $type eq 'HTML::Template::LOOP'
2832 1 1 unless ref $cgi eq 'CGI'
2871 0 624 unless @_ % 2 == 0
2875 0 624 if $$options{'memory_debug'}
2878 0 624 if $$options{'debug'}
2881 0 624 if ($$options{'stack_debug'})
2888 9 615 if $$options{'global_vars'}
2892 29 595 if (scalar @{$$options{'associate'};})
2899 0 44 if ($$options{'case_sensitive'}) { }
2907 35 35 unless (defined $self->param($param))
2909 32 13 if exists $case_map{$associated_object}{$param}
2924 1 623 if defined $args{'print_to'} and not eval { do { tied *{$args{'print_to'};} } }
2932 1333 1098 if ($type eq 'SCALAR') { }
15 1083 elsif ($type eq 'HTML::Template::VAR' and ref $$HTML::Template::line eq 'CODE') { }
293 790 elsif ($type eq 'HTML::Template::VAR') { }
73 717 elsif ($type eq 'HTML::Template::LOOP') { }
436 281 elsif ($type eq 'HTML::Template::COND') { }
145 136 elsif ($type eq 'HTML::Template::NOOP') { }
43 93 elsif ($type eq 'HTML::Template::DEFAULT') { }
37 56 elsif ($type eq 'HTML::Template::ESCAPE') { }
27 29 elsif ($type eq 'HTML::Template::JSESCAPE') { }
29 0 elsif ($type eq 'HTML::Template::URLESCAPE') { }
2935 15 0 if (defined $$HTML::Template::line)
2937 1 14 if $$options{'force_untaint'} and tainted $tmp_val
2942 1 13 if $$options{'cache_lazy_vars'}
2945 287 6 if (defined $$HTML::Template::line)
2946 1 286 if ($$options{'force_untaint'} and tainted $$HTML::Template::line)
2952 66 7 if (defined $$HTML::Template::line[1])
2954 0 66 if $@
2959 139 297 if ($$HTML::Template::line[5]) { }
2962 14 283 if ($$HTML::Template::line[2]) { }
2963 14 0 if ($$HTML::Template::line[1] == 0) { }
2964 13 1 if (defined ${$$HTML::Template::line[0];})
2965 3 10 if (ref ${$$HTML::Template::line[0];} eq 'CODE') { }
2967 1 2 if $tmp_val
2968 0 3 if $$options{'cache_lazy_vars'}
2970 4 6 if ${$$HTML::Template::line[0];}
2976 0 0 if (defined $loop_values and ref $loop_values eq 'CODE')
2978 0 0 if $$options{'cache_lazy_loops'}
2983 0 0 if (defined $loop_values and @$loop_values)
2988 272 11 if ($$HTML::Template::line[1] == 0) { }
2989 262 10 if (defined ${$$HTML::Template::line[0];}) { }
2990 205 57 if (ref ${$$HTML::Template::line[0];} eq 'CODE') { }
2992 94 111 unless $tmp_val
2993 2 203 if $$options{'cache_lazy_vars'}
2996 26 31 unless ${$$HTML::Template::line[0];}
3004 1 10 if (not defined $loop_values) { }
3008 6 4 if (ref $loop_values eq 'CODE')
3010 3 3 if $$options{'cache_lazy_loops'}
3015 3 7 unless (@$loop_values)
3029 9 4 if ref $HTML::Template::line eq 'HTML::Template::ESCAPE' or ref $HTML::Template::line eq 'HTML::Template::JSESCAPE' or ref $HTML::Template::line eq 'HTML::Template::URLESCAPE'
3035 13 30 if (defined $$HTML::Template::line) { }
3043 34 3 if (defined $$HTML::Template::line)
3045 2 32 if (ref $$HTML::Template::line eq 'CODE') { }
3047 0 2 if ($$options{'force_untaint'} > 1 and tainted $_)
3051 0 2 if $$options{'cache_lazy_vars'}
3054 0 32 if ($$options{'force_untaint'} > 1 and tainted $_)
3072 27 0 if (defined $$HTML::Template::line)
3074 2 25 if (ref $$HTML::Template::line eq 'CODE') { }
3076 0 2 if ($$options{'force_untaint'} > 1 and tainted $_)
3079 0 2 if $$options{'cache_lazy_vars'}
3082 0 25 if ($$options{'force_untaint'} > 1 and tainted $_)
3097 28 1 if (defined $$HTML::Template::line)
3099 2 26 if (ref $$HTML::Template::line eq 'CODE') { }
3101 0 2 if ($$options{'force_untaint'} > 1 and tainted $_)
3104 0 2 if $$options{'cache_lazy_vars'}
3107 0 26 if ($$options{'force_untaint'} > 1 and tainted $_)
3112 3 25 unless (exists $HTML::Template::URLESCAPE_MAP{"\cA"})
3125 9 613 if $$options{'global_vars'}
3127 0 622 if $$options{'memory_debug'}
3130 1 621 if defined $args{'print_to'}
3208 0 24 if $$self{'options'}{'debug'}
3212 2 22 unless scalar @_
3214 0 22 if scalar(@_) % 2
3216 0 22 if scalar @_ != 2
3220 0 22 unless $opt eq 'name' or $opt eq 'loop'
3224 10 12 unless ref $path
3228 1 21 unless scalar @objs
3232 13 8 if ($opt eq 'name') { }
8 0 elsif ($opt eq 'loop') { }
3236 0 13 unless defined $obj
3237 7 6 if $type eq 'HTML::Template::VAR'
3238 6 0 if $type eq 'HTML::Template::LOOP'
3245 2 10 unless defined $obj and $type eq 'HTML::Template::LOOP'
3265 0 61 $$self{'options'}{'case_sensitive'} ? :
3269 4 57 unless defined $obj
3273 36 21 unless @_
3274 0 21 unless $type eq 'HTML::Template::LOOP'
3311 0 66 unless defined $value_sets_array
3318 6 60 if (ref $value_sets_array eq 'CODE')
3320 0 6 unless ref $value_sets_array and ref $value_sets_array eq 'ARRAY'
3322 0 6 if $$template{'options'}{'cache_lazy_loops'}
3326 63 92 if ($loop_context_vars)
3327 15 48 if ($count == 0) { }
14 34 elsif ($count == $#{$value_sets_array;}) { }
3343 63 92 if $loop_context_vars