| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Clevery; |
|
2
|
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
474451
|
use 5.008_001; |
|
|
14
|
|
|
|
|
60
|
|
|
|
14
|
|
|
|
|
813
|
|
|
4
|
14
|
|
|
14
|
|
84
|
use strict; |
|
|
14
|
|
|
|
|
27
|
|
|
|
14
|
|
|
|
|
962
|
|
|
5
|
14
|
|
|
14
|
|
78
|
use warnings; |
|
|
14
|
|
|
|
|
29
|
|
|
|
14
|
|
|
|
|
1356
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.0004'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
0
|
12
|
sub smarty_compatible_version { '2.6' } |
|
10
|
|
|
|
|
|
|
|
|
11
|
14
|
|
|
14
|
|
14939
|
use parent qw(Text::Xslate); |
|
|
14
|
|
|
|
|
5264
|
|
|
|
14
|
|
|
|
|
75
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
14
|
|
|
14
|
|
231825
|
use Carp (); |
|
|
14
|
|
|
|
|
36
|
|
|
|
14
|
|
|
|
|
391
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
14
|
|
|
14
|
|
77
|
use Text::Xslate::Util qw(p); |
|
|
14
|
|
|
|
|
29
|
|
|
|
14
|
|
|
|
|
921
|
|
|
16
|
14
|
|
|
14
|
|
11530
|
use Text::Clevery::Context; |
|
|
14
|
|
|
|
|
1547
|
|
|
|
14
|
|
|
|
|
658
|
|
|
17
|
14
|
|
|
14
|
|
11506
|
use Text::Clevery::Function; |
|
|
14
|
|
|
|
|
47
|
|
|
|
14
|
|
|
|
|
581
|
|
|
18
|
14
|
|
|
14
|
|
14157
|
use Text::Clevery::Modifier; |
|
|
14
|
|
|
|
|
44
|
|
|
|
14
|
|
|
|
|
7398
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %builtin = ( |
|
21
|
|
|
|
|
|
|
'@clevery_context' => \&get_current_context, |
|
22
|
|
|
|
|
|
|
'@clevery_set_foreach_property' => \&_set_foreach_property, |
|
23
|
|
|
|
|
|
|
'@clevery_array_is_not_empty' => \&_array_is_not_empty, |
|
24
|
|
|
|
|
|
|
'@clevery_not_implemented' => \&_not_implemented, |
|
25
|
|
|
|
|
|
|
Text::Clevery::Function->methods(), |
|
26
|
|
|
|
|
|
|
Text::Clevery::Modifier->methods(), |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
14
|
|
|
14
|
0
|
3080
|
sub default_functions { \%builtin } |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub options { |
|
32
|
14
|
|
|
14
|
0
|
649
|
my($self) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
14
|
|
|
|
|
189
|
my $opts = $self->SUPER::options; |
|
35
|
|
|
|
|
|
|
|
|
36
|
14
|
|
|
|
|
2385
|
$opts->{syntax} = 'Text::Clevery::Parser'; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# set delimiters here to make access easier |
|
39
|
14
|
|
|
|
|
38
|
$opts->{tag_start} = '{'; |
|
40
|
14
|
|
|
|
|
38
|
$opts->{tag_end} = '}'; |
|
41
|
14
|
|
|
|
|
49
|
return $opts; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub render_string { |
|
45
|
110
|
|
|
110
|
1
|
62782
|
my($self, $str, $vars, @args) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
110
|
|
|
|
|
751
|
local $self->{clevery_context_args} = \@args; |
|
48
|
110
|
|
|
|
|
554
|
local $self->{clevery_context}; |
|
49
|
110
|
|
|
|
|
1666
|
return $self->SUPER::render_string($str, $vars); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub render { |
|
53
|
0
|
|
|
0
|
1
|
0
|
my($self, $str, $vars, @args) = @_; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
local $self->{clevery_context_args} = \@args; |
|
56
|
0
|
|
|
|
|
0
|
local $self->{clevery_context}; |
|
57
|
0
|
|
|
|
|
0
|
return $self->SUPER::render($str, $vars); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_current_context { |
|
61
|
127
|
50
|
|
127
|
0
|
12161
|
my $self = __PACKAGE__->current_engine() |
|
62
|
|
|
|
|
|
|
or Carp::confess("Cannot get clevery context outside render()"); |
|
63
|
23
|
|
|
|
|
516
|
return $self->{clevery_context} ||= Text::Clevery::Context->new( |
|
64
|
127
|
|
66
|
|
|
728
|
@{$self->{clevery_context_args}}, |
|
65
|
|
|
|
|
|
|
_engine => $self, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _set_foreach_property { |
|
70
|
27
|
|
|
27
|
|
22583
|
my($name, $index, $body) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
27
|
|
|
|
|
50
|
my $context = get_current_context(); |
|
73
|
|
|
|
|
|
|
|
|
74
|
27
|
|
|
|
|
36
|
my $size = scalar @{$body}; |
|
|
27
|
|
|
|
|
40
|
|
|
75
|
27
|
|
|
|
|
207
|
$context->foreach->{$name} = { |
|
76
|
|
|
|
|
|
|
index => $index, |
|
77
|
|
|
|
|
|
|
iteration => $index + 1, |
|
78
|
|
|
|
|
|
|
first => $index == 0, |
|
79
|
|
|
|
|
|
|
last => $index == ($size - 1), |
|
80
|
|
|
|
|
|
|
show => undef, # ??? |
|
81
|
|
|
|
|
|
|
total => $size, |
|
82
|
|
|
|
|
|
|
}; |
|
83
|
27
|
|
|
|
|
118
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _array_is_not_empty { |
|
87
|
3
|
|
|
3
|
|
21050
|
my($arrayref) = @_; |
|
88
|
3
|
|
100
|
|
|
27
|
return defined($arrayref) && @{$arrayref} != 0; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _not_implemented { |
|
92
|
0
|
|
|
0
|
|
|
my($name) = @_; |
|
93
|
0
|
|
|
|
|
|
die "NotImplemented: $name\n"; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
__END__ |