line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mustache::Simple::ContextStack; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
64
|
|
4
|
3
|
|
|
3
|
|
9
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
71
|
|
5
|
3
|
|
|
3
|
|
22
|
use 5.10.1; |
|
3
|
|
|
|
|
9
|
|
6
|
3
|
|
|
3
|
|
11
|
use version; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = version->declare('v1.3.5'); |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
201
|
use Scalar::Util qw(blessed reftype); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
177
|
|
11
|
3
|
|
|
3
|
|
11
|
use Carp; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
696
|
|
12
|
|
|
|
|
|
|
our @CARP_NOT = qw(Mustache::Simple); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Don't forget to change the version in the pod |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#use Data::Dumper; |
17
|
|
|
|
|
|
|
#$Data::Dumper::Useqq = 1; |
18
|
|
|
|
|
|
|
#$Data::Dumper::Deparse = 1; |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
#use Data::Dump qw(dumpf); |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
#sub debug($) |
23
|
|
|
|
|
|
|
#{ |
24
|
|
|
|
|
|
|
# say dumpf(shift, sub { |
25
|
|
|
|
|
|
|
# my ($ctx, $ref) = @_; |
26
|
|
|
|
|
|
|
# return { dump => qq(<$ref>) } if $ctx->object_isa('DateTime'); |
27
|
|
|
|
|
|
|
# } |
28
|
|
|
|
|
|
|
# ); |
29
|
|
|
|
|
|
|
# say "-" x 50; |
30
|
|
|
|
|
|
|
#} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new |
33
|
|
|
|
|
|
|
{ |
34
|
98
|
|
|
98
|
0
|
72
|
my $class = shift; |
35
|
98
|
|
|
|
|
82
|
my $self = []; |
36
|
98
|
|
|
|
|
338
|
bless $self, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub push |
40
|
|
|
|
|
|
|
{ |
41
|
222
|
|
|
222
|
0
|
140
|
my $self = shift; |
42
|
222
|
|
|
|
|
142
|
my $context = shift; |
43
|
222
|
|
|
|
|
389
|
push @$self, $context; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub pop |
47
|
|
|
|
|
|
|
{ |
48
|
222
|
|
|
222
|
0
|
150
|
my $self = shift; |
49
|
222
|
|
|
|
|
164
|
my $context = pop @$self; |
50
|
222
|
|
|
|
|
314
|
return $context; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub search |
54
|
|
|
|
|
|
|
{ |
55
|
186
|
|
|
186
|
0
|
139
|
my $self = shift; |
56
|
186
|
|
|
|
|
159
|
my $element = shift; |
57
|
186
|
|
|
|
|
351
|
for (my $i = $#$self; $i >= 0; $i--) |
58
|
|
|
|
|
|
|
{ |
59
|
302
|
|
|
|
|
225
|
my $context = $self->[$i]; |
60
|
302
|
50
|
|
|
|
524
|
if (blessed $context) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
|
|
0
|
my $meth; |
63
|
0
|
0
|
|
0
|
|
0
|
return sub { $context->$meth } if $meth = $context->can($element); |
|
0
|
|
|
|
|
0
|
|
64
|
|
|
|
|
|
|
} |
65
|
302
|
50
|
|
|
|
527
|
next unless reftype $context eq 'HASH'; |
66
|
302
|
100
|
|
|
|
865
|
return $context->{$element} if exists $context->{$element}; |
67
|
|
|
|
|
|
|
} |
68
|
5
|
|
|
|
|
9
|
return undef; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub top |
72
|
|
|
|
|
|
|
{ |
73
|
10
|
|
|
10
|
0
|
9
|
my $self = shift; |
74
|
10
|
|
|
|
|
20
|
return $self->[-1]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |