line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Blitz::Template; |
2
|
11
|
|
|
11
|
|
80
|
use HTML::Blitz::pragma; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
70
|
|
3
|
11
|
|
|
11
|
|
9683
|
use HTML::Blitz::CodeGen (); |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
358
|
|
4
|
11
|
|
|
11
|
|
82
|
use Carp qw(croak); |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
587
|
|
5
|
|
|
|
|
|
|
use constant { |
6
|
11
|
|
|
|
|
1998
|
_REPR_VERSION => 0, |
7
|
11
|
|
|
11
|
|
74
|
}; |
|
11
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
10
|
|
|
|
|
|
|
|
11
|
239
|
50
|
33
|
239
|
0
|
616
|
method new($class: :$_codegen) { |
|
239
|
50
|
|
|
|
990
|
|
|
239
|
50
|
|
|
|
409
|
|
|
239
|
50
|
|
|
|
573
|
|
|
239
|
|
|
|
|
661
|
|
|
239
|
|
|
|
|
604
|
|
|
239
|
|
|
|
|
325
|
|
12
|
239
|
|
|
|
|
1210
|
bless { |
13
|
|
|
|
|
|
|
_codegen => $_codegen, |
14
|
|
|
|
|
|
|
}, $class |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
7
|
50
|
|
7
|
|
26
|
method _codegen() { |
|
7
|
50
|
|
|
|
23
|
|
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
12
|
|
18
|
|
|
|
|
|
|
$self->{_codegen} |
19
|
7
|
|
|
|
|
100
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
1
|
1
|
7690
|
method FREEZE($model) { |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
22
|
1
|
|
|
|
|
8
|
_REPR_VERSION, $self->{_codegen}->FREEZE($model) |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
1
|
1
|
563
|
method THAW($class: $model, $repr_version, @components) { |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
26
|
1
|
50
|
|
|
|
4
|
$repr_version <= _REPR_VERSION |
27
|
|
|
|
|
|
|
or croak "Cannot deserialize data format $repr_version with $class v$VERSION, which only supports data format " . _REPR_VERSION; |
28
|
1
|
|
|
|
|
7
|
my $codegen = HTML::Blitz::CodeGen->THAW($model, @components); |
29
|
1
|
|
|
|
|
5
|
$class->new(_codegen => $codegen) |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
238
|
50
|
|
238
|
|
477
|
method _perl_src() { |
|
238
|
50
|
|
|
|
467
|
|
|
238
|
|
|
|
|
345
|
|
|
238
|
|
|
|
|
357
|
|
33
|
|
|
|
|
|
|
$self->{_perl_src} //= $self->{_codegen}->assemble( |
34
|
238
|
|
66
|
|
|
1636
|
data_format => 'sigil', |
35
|
|
|
|
|
|
|
data_format_mapping => { |
36
|
|
|
|
|
|
|
array => '', |
37
|
|
|
|
|
|
|
bool => '', |
38
|
|
|
|
|
|
|
func => '', |
39
|
|
|
|
|
|
|
html => '', |
40
|
|
|
|
|
|
|
str => '', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
) |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
1
|
1
|
13
|
method compile_to_string() { |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
46
|
1
|
|
|
|
|
3
|
$self->_perl_src |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
2
|
1
|
1903
|
method compile_to_fh($fh, $name = $fh) { |
|
2
|
50
|
|
|
|
6
|
|
|
2
|
100
|
|
|
|
5
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
5
|
|
50
|
2
|
50
|
|
|
|
9
|
print $fh $self->_perl_src |
51
|
|
|
|
|
|
|
or croak "Can't write to $name: $!"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
33
|
1
|
1
|
1268
|
method compile_to_file($file, :$do_sync = undef) { |
|
1
|
50
|
|
|
|
6
|
|
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
55
|
1
|
50
|
|
|
|
64
|
open my $fh, '>:encoding(UTF-8)', $file |
56
|
|
|
|
|
|
|
or croak "Can't open $file: $!"; |
57
|
1
|
|
|
|
|
73
|
$self->compile_to_fh($fh, $file); |
58
|
1
|
50
|
|
|
|
5
|
if ($do_sync) { |
59
|
0
|
0
|
|
|
|
0
|
$fh->flush |
60
|
|
|
|
|
|
|
or croak "Can't flush $file: $!"; |
61
|
0
|
0
|
|
|
|
0
|
$fh->sync |
62
|
|
|
|
|
|
|
or croak "Can't sync $file: $!"; |
63
|
|
|
|
|
|
|
} |
64
|
1
|
50
|
|
|
|
110
|
close $fh |
65
|
|
|
|
|
|
|
or croak "Can't close $file: $!"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
235
|
50
|
|
235
|
1
|
461
|
method compile_to_sub() { |
|
235
|
50
|
|
|
|
461
|
|
|
235
|
|
|
|
|
332
|
|
|
235
|
|
|
|
|
317
|
|
69
|
235
|
|
33
|
|
|
1403
|
$self->{_sub} //= do { |
70
|
235
|
|
|
|
|
379
|
my $err; |
71
|
235
|
|
|
|
|
504
|
my $src = $self->_perl_src; |
72
|
235
|
|
|
|
|
872
|
my $fn; |
73
|
|
|
|
|
|
|
{ |
74
|
235
|
|
|
|
|
369
|
local $@; |
|
235
|
|
|
|
|
379
|
|
75
|
235
|
|
|
|
|
20922
|
$fn = eval $src; |
76
|
235
|
|
|
|
|
58007
|
$err = $@; |
77
|
|
|
|
|
|
|
} |
78
|
235
|
|
33
|
|
|
1606
|
$fn // croak $err |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
232
|
50
|
|
232
|
1
|
1270
|
method process($data = {}) { |
|
232
|
50
|
|
|
|
467
|
|
|
232
|
100
|
|
|
|
377
|
|
|
232
|
|
|
|
|
630
|
|
|
232
|
|
|
|
|
298
|
|
83
|
232
|
|
|
|
|
501
|
$self->compile_to_sub->($data) |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1 |
87
|
|
|
|
|
|
|
__END__ |