line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
21
|
|
|
21
|
|
13603
|
use strict; |
|
21
|
|
|
|
|
43
|
|
|
21
|
|
|
|
|
779
|
|
3
|
21
|
|
|
21
|
|
101
|
use warnings; |
|
21
|
|
|
|
|
34
|
|
|
21
|
|
|
|
|
744
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Tag::Capture; |
6
|
21
|
|
|
21
|
|
92
|
use base 'WWW::Shopify::Liquid::Tag::Enclosing'; |
|
21
|
|
|
|
|
32
|
|
|
21
|
|
|
|
|
2203
|
|
7
|
0
|
|
|
0
|
0
|
0
|
sub min_arguments { return 1; } |
8
|
0
|
|
|
0
|
0
|
0
|
sub max_arguments { return 1; } |
9
|
21
|
|
|
21
|
|
121
|
use Scalar::Util qw(blessed); |
|
21
|
|
|
|
|
29
|
|
|
21
|
|
|
|
|
6918
|
|
10
|
|
|
|
|
|
|
sub process { |
11
|
0
|
|
|
0
|
0
|
0
|
my ($self, $hash, $action) = @_; |
12
|
0
|
0
|
|
|
|
0
|
my @vars = map { $self->is_processed($_) ? $_ : $_->process($hash, $action) } @{$self->{arguments}->[0]->{core}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
13
|
0
|
0
|
0
|
|
|
0
|
return $self if $action eq "optimize" && int(grep { !$self->is_processed($_) } @vars) > 0; |
|
0
|
|
|
|
|
0
|
|
14
|
0
|
|
|
|
|
0
|
my $inner_hash = $hash; |
15
|
0
|
|
|
|
|
0
|
for (0..$#vars-1) { |
16
|
0
|
0
|
0
|
|
|
0
|
return $self if !exists $inner_hash->{$vars[$_]} && $action eq 'optimize'; |
17
|
0
|
0
|
|
|
|
0
|
$inner_hash->{$vars[$_]} = {} if !exists $inner_hash->{$vars[$_]}; |
18
|
0
|
|
|
|
|
0
|
$inner_hash = $inner_hash->{$vars[$_]}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
# For now, only do renders. |
21
|
0
|
0
|
|
|
|
0
|
if ($action eq "optimize") { |
22
|
|
|
|
|
|
|
# If we run across something that should be assigned, we must delete it in the hash to preserve uncertainty. |
23
|
0
|
|
|
|
|
0
|
delete $inner_hash->{$vars[-1]}; |
24
|
0
|
|
|
|
|
0
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
0
|
my $result = $self->{contents}->$action($hash); |
27
|
0
|
0
|
|
|
|
0
|
return $self unless $self->is_processed($result); |
28
|
0
|
|
|
|
|
0
|
$inner_hash->{$vars[-1]} = $result; |
29
|
0
|
|
|
|
|
0
|
return ''; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub verify { |
33
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
34
|
1
|
50
|
|
|
|
13
|
die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires a variable to be the capture target.") unless |
35
|
|
|
|
|
|
|
$self->{arguments}->[0]->isa('WWW::Shopify::Liquid::Token::Variable'); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |