| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Markapl; |
|
2
|
25
|
|
|
25
|
|
377366
|
use strict; |
|
|
22
|
|
|
|
|
48
|
|
|
|
22
|
|
|
|
|
768
|
|
|
3
|
22
|
|
|
22
|
|
112
|
use warnings; |
|
|
22
|
|
|
|
|
37
|
|
|
|
22
|
|
|
|
|
608
|
|
|
4
|
22
|
|
|
22
|
|
24311
|
use Devel::Declare (); |
|
|
22
|
|
|
|
|
181310
|
|
|
|
22
|
|
|
|
|
727
|
|
|
5
|
22
|
|
|
22
|
|
21794
|
use Sub::Install qw(install_sub); |
|
|
22
|
|
|
|
|
44046
|
|
|
|
22
|
|
|
|
|
143
|
|
|
6
|
22
|
|
|
22
|
|
18125
|
use Markapl::Tags; |
|
|
22
|
|
|
|
|
223
|
|
|
|
22
|
|
|
|
|
583
|
|
|
7
|
22
|
|
|
22
|
|
13443
|
use Markapl::TagHandlers; |
|
|
22
|
|
|
|
|
74
|
|
|
|
22
|
|
|
|
|
665
|
|
|
8
|
22
|
|
|
22
|
|
166
|
use String::BufferStack; |
|
|
22
|
|
|
|
|
40
|
|
|
|
22
|
|
|
|
|
391
|
|
|
9
|
22
|
|
|
22
|
|
113
|
use HTML::Entities; |
|
|
22
|
|
|
|
|
46
|
|
|
|
22
|
|
|
|
|
1317
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
22
|
|
|
22
|
|
710
|
use 5.008; |
|
|
22
|
|
|
|
|
114
|
|
|
|
22
|
|
|
|
|
24496
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = "0.14"; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $buffer; |
|
15
|
|
|
|
|
|
|
sub buffer { |
|
16
|
457
|
100
|
|
457
|
0
|
1024
|
$buffer = $_[1] if $_[1]; |
|
17
|
457
|
|
66
|
42
|
|
2570
|
$buffer ||= String::BufferStack->new( out_method => sub { join("", @_) }); |
|
|
42
|
|
|
|
|
605
|
|
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub template { |
|
21
|
96
|
|
|
96
|
1
|
5475
|
my ($name, $code) = @_; |
|
22
|
96
|
|
|
|
|
177
|
my $caller = caller; |
|
23
|
96
|
|
|
|
|
550
|
install_sub({ |
|
24
|
|
|
|
|
|
|
code => $code, |
|
25
|
|
|
|
|
|
|
into => $caller, |
|
26
|
|
|
|
|
|
|
as => $name |
|
27
|
|
|
|
|
|
|
}); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub outs_raw($) { |
|
31
|
12
|
|
|
12
|
0
|
2592
|
my $str = shift; |
|
32
|
12
|
|
|
|
|
40
|
Markapl->buffer->append( $str ); |
|
33
|
12
|
|
|
|
|
176
|
return ''; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub outs($) { |
|
37
|
11
|
|
|
11
|
1
|
80
|
my $str = shift; |
|
38
|
11
|
|
|
|
|
56
|
outs_raw encode_entities($str, '<>&"'); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub render { |
|
42
|
43
|
|
|
43
|
1
|
24655
|
my ($self, $template, @vars) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
43
|
100
|
|
|
|
398
|
if (my $sub = $self->can($template)) { |
|
45
|
42
|
|
|
|
|
215
|
Markapl->buffer->push; |
|
46
|
42
|
|
|
|
|
1512
|
$sub->($self, @vars); |
|
47
|
42
|
|
|
|
|
206
|
my $buf = Markapl->buffer->pop; |
|
48
|
42
|
|
|
|
|
1412
|
Markapl->buffer->flush_output; |
|
49
|
42
|
|
|
|
|
365
|
return $buf |
|
50
|
|
|
|
|
|
|
} else { |
|
51
|
1
|
|
|
|
|
9
|
require Carp; |
|
52
|
1
|
|
|
|
|
266
|
Carp::croak( "no such template: $template in $self" ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set { |
|
57
|
1
|
|
|
1
|
1
|
23
|
my ($self, $name, $value) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
10
|
if ($self->can("stash")) { |
|
|
|
0
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
45
|
$self->stash->{$name} = $value; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
elsif ((my $caller = caller)->can("stash")) { |
|
63
|
0
|
|
|
|
|
0
|
$caller->stash->{$name} = $value; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get { |
|
68
|
5
|
|
|
5
|
1
|
18
|
my ($self, $name) = @_; |
|
69
|
5
|
100
|
66
|
|
|
31
|
if (defined($name) && $self->can("stash")) { |
|
70
|
3
|
|
100
|
|
|
84
|
return $self->stash->{$name} || "" |
|
71
|
|
|
|
|
|
|
} |
|
72
|
2
|
|
|
|
|
5
|
$name = $self, $self = caller; |
|
73
|
2
|
|
|
|
|
7
|
$self->get($name); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub import { |
|
77
|
29
|
|
|
29
|
|
3174
|
my ($class) = @_; |
|
78
|
29
|
|
|
|
|
74
|
my $caller = caller; |
|
79
|
|
|
|
|
|
|
|
|
80
|
29
|
|
|
|
|
91
|
for my $name (qw(render outs outs_raw template get set)) { |
|
81
|
174
|
|
|
|
|
9894
|
install_sub({ |
|
82
|
|
|
|
|
|
|
code => $name, |
|
83
|
|
|
|
|
|
|
into => $caller, |
|
84
|
|
|
|
|
|
|
}); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
29
|
|
|
|
|
1420
|
my $config = {}; |
|
88
|
29
|
|
|
|
|
1440
|
my $code_str = qq{package $caller; my \$stash = {}; sub stash { \$stash } }; |
|
89
|
|
|
|
|
|
|
|
|
90
|
29
|
|
|
|
|
202
|
for my $tag ( Markapl::Tags->html() ) { |
|
91
|
2726
|
|
|
|
|
5921
|
$code_str .= qq{sub $tag (&);}; |
|
92
|
2726
|
|
|
|
|
5639
|
$config->{$tag} = { |
|
93
|
|
|
|
|
|
|
const => Markapl::TagHandlers::tag_parser_for($tag) |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
29
|
|
|
1
|
0
|
24996
|
eval $code_str; |
|
|
1
|
|
|
|
|
10
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
29
|
|
|
|
|
305
|
Devel::Declare->setup_for($caller, $config); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
__END__ |