line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
30
|
|
|
30
|
|
16966
|
use strict; |
|
30
|
|
|
|
|
62
|
|
|
30
|
|
|
|
|
840
|
|
3
|
30
|
|
|
30
|
|
121
|
use warnings; |
|
30
|
|
|
|
|
53
|
|
|
30
|
|
|
|
|
960
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Tag::Include; |
6
|
30
|
|
|
30
|
|
130
|
use base 'WWW::Shopify::Liquid::Tag::Free'; |
|
30
|
|
|
|
|
54
|
|
|
30
|
|
|
|
|
2122
|
|
7
|
30
|
|
|
30
|
|
149
|
use File::Slurp; |
|
30
|
|
|
|
|
48
|
|
|
30
|
|
|
|
|
20160
|
|
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
0
|
|
sub max_arguments { return 1; } |
10
|
0
|
|
|
0
|
0
|
|
sub min_arguments { return 1; } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub verify { |
13
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub retrieve_include { |
17
|
0
|
|
|
0
|
0
|
|
my ($self, $hash, $action, $pipeline, $string, $argument) = @_; |
18
|
0
|
0
|
0
|
|
|
|
if ($pipeline->inclusion_context && $pipeline->parent) { |
|
|
0
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Inclusion contexts are evaluated from left to right, in order of priority. |
20
|
0
|
0
|
0
|
|
|
|
my @inclusion_contexts = $pipeline->inclusion_context && ref($pipeline->inclusion_context) && ref($pipeline->inclusion_context) eq "ARRAY" ? @{$pipeline->inclusion_context} : $pipeline->inclusion_context; |
|
0
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
die new WWW::Shopify::Liquid::Exception([], "Backtracking not allowed in inclusions.") if $string =~ m/\.\./; |
22
|
0
|
|
|
|
|
|
for (@inclusion_contexts) { |
23
|
0
|
|
|
|
|
|
my $path = $_ . "/" . $string . ".liquid"; |
24
|
0
|
0
|
|
|
|
|
return ($path, scalar(read_file($path))) if -e $path; |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
die new WWW::Shopify::Liquid::Exception([], "Can't find include $string."); |
27
|
|
|
|
|
|
|
} elsif ($action eq "render") { |
28
|
0
|
|
|
|
|
|
die new WWW::Shopify::Liquid::Exception::Renderer::Unimplemented($self); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub process_include { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $hash, $action, $pipeline, $path, $text) = @_; |
35
|
0
|
|
|
|
|
|
my $old_context = $pipeline->parent->lexer->file_context; |
36
|
0
|
|
|
|
|
|
$pipeline->parent->lexer->file_context($path); |
37
|
0
|
|
|
|
|
|
$pipeline->parent->parser->file_context($path); |
38
|
0
|
|
|
|
|
|
$pipeline->parent->renderer->file_context($path); |
39
|
0
|
|
|
|
|
|
my $ast = $pipeline->parent->parse_text($text); |
40
|
0
|
0
|
|
|
|
|
if ($action eq "optimize") { |
41
|
0
|
|
|
|
|
|
$ast = $pipeline->optimize($hash, $ast); |
42
|
0
|
|
|
|
|
|
$pipeline->parent->lexer->file_context($old_context); |
43
|
0
|
|
|
|
|
|
$pipeline->parent->parser->file_context($old_context); |
44
|
0
|
|
|
|
|
|
$pipeline->parent->renderer->file_context($old_context); |
45
|
0
|
|
|
|
|
|
return $ast; |
46
|
|
|
|
|
|
|
} else { |
47
|
|
|
|
|
|
|
# Perform no hash cloning. |
48
|
0
|
|
|
|
|
|
my $clone_hash = $pipeline->clone_hash; |
49
|
0
|
|
|
|
|
|
$pipeline->clone_hash(0); |
50
|
0
|
|
|
|
|
|
my ($result) = $pipeline->render($hash, $ast); |
51
|
0
|
|
|
|
|
|
$pipeline->clone_hash($clone_hash); |
52
|
0
|
|
|
|
|
|
$pipeline->parent->lexer->file_context($old_context); |
53
|
0
|
|
|
|
|
|
$pipeline->parent->parser->file_context($old_context); |
54
|
0
|
|
|
|
|
|
$pipeline->parent->renderer->file_context($old_context); |
55
|
0
|
|
|
|
|
|
return $result; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub process { |
60
|
0
|
|
|
0
|
0
|
|
my ($self, $hash, $action, $pipeline) = @_; |
61
|
0
|
0
|
|
|
|
|
die new WWW::Shopify::Liquid::Exception([], "Recursive inclusion probable, greater than depth " . $pipeline->max_inclusion_depth . ". Aborting.") |
62
|
|
|
|
|
|
|
if $pipeline->inclusion_depth > $pipeline->max_inclusion_depth; |
63
|
0
|
0
|
|
|
|
|
return '' unless int(@{$self->{arguments}}) > 0; |
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $result = $self->{arguments}->[0]->$action($pipeline, $hash); |
65
|
0
|
|
|
|
|
|
my ($string, $argument); |
66
|
0
|
0
|
0
|
|
|
|
if ($result && ref($result) && $result->isa('WWW::Shopify::Liquid::Operator::With')) { |
|
|
|
0
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$string = $result->{arguments}->[0]; |
68
|
0
|
|
|
|
|
|
$argument = $result->{arguments}->[1]; |
69
|
|
|
|
|
|
|
} else { |
70
|
0
|
|
|
|
|
|
$string = $result; |
71
|
|
|
|
|
|
|
} |
72
|
0
|
0
|
0
|
|
|
|
return $self if !$self->is_processed($string) || !$self->is_processed($argument); |
73
|
0
|
|
|
|
|
|
my ($path, $text) = $self->retrieve_include($hash, $action, $pipeline, $string, $argument); |
74
|
0
|
0
|
|
|
|
|
return $self if !$self->is_processed($path); |
75
|
0
|
|
|
|
|
|
my $include_depth = $pipeline->inclusion_depth; |
76
|
0
|
|
|
|
|
|
$pipeline->inclusion_depth($include_depth+1); |
77
|
0
|
|
|
|
|
|
$result = $self->process_include($hash, $action, $pipeline, $path, $text); |
78
|
0
|
|
|
|
|
|
$pipeline->inclusion_depth($include_depth); |
79
|
0
|
|
|
|
|
|
return $result; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |