line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
37
|
|
|
37
|
|
276
|
use strict; |
|
37
|
|
|
|
|
119
|
|
|
37
|
|
|
|
|
1253
|
|
4
|
37
|
|
|
37
|
|
256
|
use warnings; |
|
37
|
|
|
|
|
106
|
|
|
37
|
|
|
|
|
1425
|
|
5
|
|
|
|
|
|
|
|
6
|
37
|
|
|
37
|
|
250
|
use WWW::Shopify::Liquid; |
|
37
|
|
|
|
|
163
|
|
|
37
|
|
|
|
|
2711
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Designed to wrap objects in the hash taht shoudln't be cloned. Only works for top level. |
9
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Renderer::NoClone; |
10
|
0
|
|
|
0
|
|
0
|
sub new { return bless { inner => $_[1] }, $_[0]; } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Renderer; |
13
|
37
|
|
|
37
|
|
262
|
use base 'WWW::Shopify::Liquid::Pipeline'; |
|
37
|
|
|
|
|
99
|
|
|
37
|
|
|
|
|
4795
|
|
14
|
37
|
|
|
37
|
|
293
|
use WWW::Shopify::Liquid::Security; |
|
37
|
|
|
|
|
104
|
|
|
37
|
|
|
|
|
889
|
|
15
|
37
|
|
|
37
|
|
235
|
use DateTime; |
|
37
|
|
|
|
|
97
|
|
|
37
|
|
|
|
|
918
|
|
16
|
37
|
|
|
37
|
|
11650
|
use WWW::Shopify::Liquid::Resolver; |
|
37
|
|
|
|
|
132
|
|
|
37
|
|
|
|
|
18057
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# WATCH THIS CLONING. IT CAN CAUSE SEGFAULTS DEPENDING ON WHAT'S CLONED. |
19
|
85
|
|
|
85
|
0
|
275
|
sub new { my $package = shift; return bless { clone_hash => 1, silence_exceptions => 1, wrap_exceptions => 0, print_exceptions => 0, default_variables => { |
20
|
1
|
|
|
1
|
|
10
|
now => WWW::Shopify::Liquid::Resolver->new(sub { return DateTime->now; }) |
21
|
85
|
|
|
|
|
1156
|
}, timeout => undef, max_inclusion_depth => 5, inclusion_context => undef, inclusion_depth => 0, security => WWW::Shopify::Liquid::Security->new, @_ }, $package; } |
22
|
432
|
100
|
|
432
|
0
|
1056
|
sub clone_hash { $_[0]->{clone_hash} = $_[1] if defined $_[1]; return $_[0]->{clone_hash}; } |
|
432
|
|
|
|
|
10463
|
|
23
|
946
|
100
|
|
946
|
0
|
2557
|
sub security { $_[0]->{security} = $_[1] if defined $_[1]; return $_[0]->{security}; } |
|
946
|
|
|
|
|
4585
|
|
24
|
0
|
0
|
|
0
|
0
|
0
|
sub print_exceptions { $_[0]->{print_exceptions} = $_[1] if defined $_[1]; return $_[0]->{print_exceptions}; } |
|
0
|
|
|
|
|
0
|
|
25
|
1
|
50
|
|
1
|
0
|
5
|
sub silence_exceptions { $_[0]->{silence_exceptions} = $_[1] if defined $_[1]; return $_[0]->{silence_exceptions}; } |
|
1
|
|
|
|
|
3
|
|
26
|
0
|
0
|
|
0
|
0
|
0
|
sub wrap_exceptions { $_[0]->{wrap_exceptions} = $_[1] if defined $_[1]; return $_[0]->{wrap_exceptions}; } |
|
0
|
|
|
|
|
0
|
|
27
|
207
|
50
|
|
207
|
0
|
637
|
sub timeout { $_[0]->{timeout} = $_[1] if defined $_[1]; return $_[0]->{timeout}; } |
|
207
|
|
|
|
|
674
|
|
28
|
11
|
50
|
|
11
|
0
|
29
|
sub max_inclusion_depth { $_[0]->{max_inclusion_depth} = $_[1] if defined $_[1]; return $_[0]->{max_inclusion_depth}; } |
|
11
|
|
|
|
|
52
|
|
29
|
34
|
100
|
|
34
|
0
|
62
|
sub inclusion_context { $_[0]->{inclusion_context} = $_[1] if defined $_[1]; return $_[0]->{inclusion_context}; } |
|
34
|
|
|
|
|
142
|
|
30
|
31
|
100
|
|
31
|
0
|
77
|
sub inclusion_depth { $_[0]->{inclusion_depth} = $_[1] if defined $_[1]; return $_[0]->{inclusion_depth}; } |
|
31
|
|
|
|
|
71
|
|
31
|
207
|
50
|
|
207
|
0
|
632
|
sub default_variables { $_[0]->{default_variants} = $_[1] if @_ > 1; return $_[0]->{default_variables}; } |
|
207
|
|
|
|
|
557
|
|
32
|
|
|
|
|
|
|
|
33
|
37
|
|
|
37
|
|
330
|
use Clone qw(clone); |
|
37
|
|
|
|
|
102
|
|
|
37
|
|
|
|
|
13729
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub render { |
36
|
207
|
|
|
207
|
0
|
11094
|
my ($self, $hash, $ast) = @_; |
37
|
207
|
0
|
33
|
|
|
716
|
return '' if !$ast && !wantarray; |
38
|
207
|
100
|
66
|
|
|
747
|
my $hash_clone = $self->clone_hash && $self->clone_hash == 1 ? clone($hash) : $hash; |
39
|
207
|
50
|
|
|
|
856
|
return ('', $hash_clone) unless $ast; |
40
|
207
|
|
|
|
|
863
|
my $default_variables = $self->default_variables; |
41
|
207
|
|
|
|
|
821
|
$hash_clone->{$_} = $default_variables->{$_} for (grep { !exists $hash_clone->{$_} } keys(%$default_variables)); |
|
207
|
|
|
|
|
1116
|
|
42
|
207
|
|
|
|
|
455
|
my $result; |
43
|
207
|
|
|
|
|
451
|
eval { |
44
|
207
|
|
|
0
|
|
2967
|
local $SIG{ALRM} = sub { die new WWW::Shopify::Liquid::Exception::Timeout(); }; |
|
0
|
|
|
|
|
0
|
|
45
|
207
|
50
|
|
|
|
881
|
alarm $self->timeout if $self->timeout; |
46
|
207
|
50
|
|
|
|
1893
|
$result = $ast->isa('WWW::Shopify::Liquid::Element') ? $ast->render($self, $hash_clone) : "$ast"; |
47
|
202
|
|
|
|
|
2563
|
alarm 0; |
48
|
|
|
|
|
|
|
}; |
49
|
207
|
100
|
|
|
|
744
|
if (my $exp = $@) { |
50
|
5
|
|
|
|
|
35
|
die $exp; |
51
|
|
|
|
|
|
|
} |
52
|
202
|
100
|
|
|
|
7311
|
return $result unless wantarray; |
53
|
59
|
|
|
|
|
507
|
return ($result, $hash_clone); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
8821
|
100
|
|
8821
|
0
|
24382
|
sub state { $_[0]->{state} = $_[1] if @_ > 1; return $_[0]->{state}; } |
|
8821
|
|
|
|
|
32015
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Used to resume execution. |
59
|
|
|
|
|
|
|
sub resume { |
60
|
5
|
|
|
5
|
0
|
20
|
my ($self, $state, $ast) = @_; |
61
|
5
|
|
|
|
|
24
|
$self->state($state); |
62
|
5
|
|
|
|
|
28
|
return $self->render($state->{hash}, $ast); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |