line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Blitz::Template; |
2
|
11
|
|
|
11
|
|
77
|
use HTML::Blitz::pragma; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
68
|
|
3
|
11
|
|
|
11
|
|
9700
|
use HTML::Blitz::CodeGen (); |
|
11
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
344
|
|
4
|
11
|
|
|
11
|
|
78
|
use Carp qw(croak); |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
579
|
|
5
|
|
|
|
|
|
|
use constant { |
6
|
11
|
|
|
|
|
2023
|
_REPR_VERSION => 0, |
7
|
11
|
|
|
11
|
|
88
|
}; |
|
11
|
|
|
|
|
25
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
10
|
|
|
|
|
|
|
|
11
|
237
|
50
|
33
|
237
|
0
|
582
|
method new($class: :$_codegen) { |
|
237
|
50
|
|
|
|
1010
|
|
|
237
|
50
|
|
|
|
495
|
|
|
237
|
50
|
|
|
|
594
|
|
|
237
|
|
|
|
|
626
|
|
|
237
|
|
|
|
|
536
|
|
|
237
|
|
|
|
|
293
|
|
12
|
237
|
|
|
|
|
1244
|
bless { |
13
|
|
|
|
|
|
|
_codegen => $_codegen, |
14
|
|
|
|
|
|
|
}, $class |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
6
|
50
|
|
6
|
|
21
|
method _codegen() { |
|
6
|
50
|
|
|
|
18
|
|
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
9
|
|
18
|
|
|
|
|
|
|
$self->{_codegen} |
19
|
6
|
|
|
|
|
92
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
1
|
1
|
8037
|
method FREEZE($model) { |
|
1
|
50
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
22
|
1
|
|
|
|
|
11
|
_REPR_VERSION, $self->{_codegen}->FREEZE($model) |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
1
|
1
|
657
|
method THAW($class: $model, $repr_version, @components) { |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
26
|
1
|
50
|
|
|
|
5
|
$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
|
|
|
|
|
10
|
my $codegen = HTML::Blitz::CodeGen->THAW($model, @components); |
29
|
1
|
|
|
|
|
6
|
$class->new(_codegen => $codegen) |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
237
|
50
|
|
237
|
|
526
|
method _perl_src() { |
|
237
|
50
|
|
|
|
441
|
|
|
237
|
|
|
|
|
333
|
|
|
237
|
|
|
|
|
286
|
|
33
|
|
|
|
|
|
|
$self->{_perl_src} //= $self->{_codegen}->assemble( |
34
|
237
|
|
66
|
|
|
1648
|
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
|
10
|
method compile_to_string() { |
|
1
|
50
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
46
|
1
|
|
|
|
|
4
|
$self->_perl_src |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
2
|
1
|
2269
|
method compile_to_fh($fh, $name = $fh) { |
|
2
|
50
|
|
|
|
7
|
|
|
2
|
100
|
|
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
50
|
2
|
50
|
|
|
|
7
|
print $fh $self->_perl_src |
51
|
|
|
|
|
|
|
or croak "Can't write to $name: $!"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
33
|
1
|
1
|
1520
|
method compile_to_file($file, :$do_sync = undef) { |
|
1
|
50
|
|
|
|
5
|
|
|
1
|
50
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
55
|
1
|
50
|
|
|
|
70
|
open my $fh, '>:encoding(UTF-8)', $file |
56
|
|
|
|
|
|
|
or croak "Can't open $file: $!"; |
57
|
1
|
|
|
|
|
81
|
$self->compile_to_fh($fh, $file); |
58
|
1
|
50
|
|
|
|
25
|
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
|
|
|
|
164
|
close $fh |
65
|
|
|
|
|
|
|
or croak "Can't close $file: $!"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
234
|
50
|
|
234
|
1
|
468
|
method compile_to_sub() { |
|
234
|
50
|
|
|
|
475
|
|
|
234
|
|
|
|
|
332
|
|
|
234
|
|
|
|
|
310
|
|
69
|
234
|
|
33
|
|
|
1385
|
$self->{_sub} //= do { |
70
|
234
|
|
|
|
|
340
|
my $err; |
71
|
234
|
|
|
|
|
561
|
my $src = $self->_perl_src; |
72
|
234
|
|
|
|
|
872
|
my $fn; |
73
|
|
|
|
|
|
|
{ |
74
|
234
|
|
|
|
|
343
|
local $@; |
|
234
|
|
|
|
|
334
|
|
75
|
234
|
|
|
|
|
20685
|
$fn = eval $src; |
76
|
234
|
|
|
|
|
56296
|
$err = $@; |
77
|
|
|
|
|
|
|
} |
78
|
234
|
|
33
|
|
|
1572
|
$fn // croak $err |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
231
|
50
|
|
231
|
1
|
1338
|
method process($data = {}) { |
|
231
|
50
|
|
|
|
435
|
|
|
231
|
100
|
|
|
|
325
|
|
|
231
|
|
|
|
|
650
|
|
|
231
|
|
|
|
|
317
|
|
83
|
231
|
|
|
|
|
519
|
$self->compile_to_sub->($data) |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1 |
87
|
|
|
|
|
|
|
__END__ |