line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Blitz::Template; |
2
|
11
|
|
|
11
|
|
84
|
use HTML::Blitz::pragma; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
68
|
|
3
|
11
|
|
|
11
|
|
9849
|
use HTML::Blitz::CodeGen (); |
|
11
|
|
|
|
|
36
|
|
|
11
|
|
|
|
|
356
|
|
4
|
11
|
|
|
11
|
|
81
|
use Carp qw(croak); |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
600
|
|
5
|
|
|
|
|
|
|
use constant { |
6
|
11
|
|
|
|
|
2211
|
_REPR_VERSION => 0, |
7
|
11
|
|
|
11
|
|
70
|
}; |
|
11
|
|
|
|
|
25
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
10
|
|
|
|
|
|
|
|
11
|
237
|
50
|
33
|
237
|
0
|
595
|
method new($class: :$_codegen) { |
|
237
|
50
|
|
|
|
986
|
|
|
237
|
50
|
|
|
|
410
|
|
|
237
|
50
|
|
|
|
561
|
|
|
237
|
|
|
|
|
624
|
|
|
237
|
|
|
|
|
570
|
|
|
237
|
|
|
|
|
294
|
|
12
|
237
|
|
|
|
|
1164
|
bless { |
13
|
|
|
|
|
|
|
_codegen => $_codegen, |
14
|
|
|
|
|
|
|
}, $class |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
6
|
50
|
|
6
|
|
21
|
method _codegen() { |
|
6
|
50
|
|
|
|
18
|
|
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
11
|
|
18
|
|
|
|
|
|
|
$self->{_codegen} |
19
|
6
|
|
|
|
|
89
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
1
|
1
|
7815
|
method FREEZE($model) { |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
22
|
1
|
|
|
|
|
9
|
_REPR_VERSION, $self->{_codegen}->FREEZE($model) |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
1
|
1
|
567
|
method THAW($class: $model, $repr_version, @components) { |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
26
|
1
|
50
|
|
|
|
13
|
$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
|
|
|
|
|
12
|
my $codegen = HTML::Blitz::CodeGen->THAW($model, @components); |
29
|
1
|
|
|
|
|
4
|
$class->new(_codegen => $codegen) |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
237
|
50
|
|
237
|
|
467
|
method _perl_src() { |
|
237
|
50
|
|
|
|
455
|
|
|
237
|
|
|
|
|
310
|
|
|
237
|
|
|
|
|
398
|
|
33
|
|
|
|
|
|
|
$self->{_perl_src} //= $self->{_codegen}->assemble( |
34
|
237
|
|
66
|
|
|
1657
|
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
|
|
|
|
|
3
|
|
46
|
1
|
|
|
|
|
3
|
$self->_perl_src |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
2
|
1
|
1829
|
method compile_to_fh($fh, $name = $fh) { |
|
2
|
50
|
|
|
|
7
|
|
|
2
|
100
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
3
|
|
50
|
2
|
50
|
|
|
|
6
|
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
|
|
|
|
5
|
|
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
55
|
1
|
50
|
|
|
|
74
|
open my $fh, '>:encoding(UTF-8)', $file |
56
|
|
|
|
|
|
|
or croak "Can't open $file: $!"; |
57
|
1
|
|
|
|
|
72
|
$self->compile_to_fh($fh, $file); |
58
|
1
|
50
|
|
|
|
4
|
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
|
|
|
|
154
|
close $fh |
65
|
|
|
|
|
|
|
or croak "Can't close $file: $!"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
234
|
50
|
|
234
|
1
|
462
|
method compile_to_sub() { |
|
234
|
50
|
|
|
|
446
|
|
|
234
|
|
|
|
|
340
|
|
|
234
|
|
|
|
|
293
|
|
69
|
234
|
|
33
|
|
|
1452
|
$self->{_sub} //= do { |
70
|
234
|
|
|
|
|
375
|
my $err; |
71
|
234
|
|
|
|
|
539
|
my $src = $self->_perl_src; |
72
|
234
|
|
|
|
|
854
|
my $fn; |
73
|
|
|
|
|
|
|
{ |
74
|
234
|
|
|
|
|
351
|
local $@; |
|
234
|
|
|
|
|
342
|
|
75
|
234
|
|
|
|
|
20527
|
$fn = eval $src; |
76
|
234
|
|
|
|
|
57700
|
$err = $@; |
77
|
|
|
|
|
|
|
} |
78
|
234
|
|
33
|
|
|
1672
|
$fn // croak $err |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
231
|
50
|
|
231
|
1
|
1236
|
method process($data = {}) { |
|
231
|
50
|
|
|
|
461
|
|
|
231
|
100
|
|
|
|
349
|
|
|
231
|
|
|
|
|
632
|
|
|
231
|
|
|
|
|
314
|
|
83
|
231
|
|
|
|
|
549
|
$self->compile_to_sub->($data) |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1 |
87
|
|
|
|
|
|
|
__END__ |