line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
30
|
|
|
30
|
|
15136
|
use strict; |
|
30
|
|
|
|
|
49
|
|
|
30
|
|
|
|
|
820
|
|
3
|
30
|
|
|
30
|
|
118
|
use warnings; |
|
30
|
|
|
|
|
45
|
|
|
30
|
|
|
|
|
1013
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Tag::Capture; |
6
|
30
|
|
|
30
|
|
123
|
use base 'WWW::Shopify::Liquid::Tag::Enclosing'; |
|
30
|
|
|
|
|
38
|
|
|
30
|
|
|
|
|
2902
|
|
7
|
0
|
|
|
0
|
0
|
|
sub min_arguments { return 1; } |
8
|
0
|
|
|
0
|
0
|
|
sub max_arguments { return 1; } |
9
|
30
|
|
|
30
|
|
163
|
use Scalar::Util qw(blessed looks_like_number); |
|
30
|
|
|
|
|
54
|
|
|
30
|
|
|
|
|
13238
|
|
10
|
|
|
|
|
|
|
sub process { |
11
|
0
|
|
|
0
|
0
|
|
my ($self, $hash, $action, $pipeline) = @_; |
12
|
0
|
0
|
|
|
|
|
my @vars = map { $self->is_processed($_) ? $_ : $_->$action($pipeline, $hash) } @{$self->{arguments}->[0]->{core}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
0
|
0
|
0
|
|
|
|
return $self if $action eq "optimize" && int(grep { !$self->is_processed($_) } @vars) > 0; |
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $inner_hash = $hash; |
16
|
0
|
|
|
|
|
|
for (0..$#vars-1) { |
17
|
0
|
0
|
0
|
|
|
|
return $self if ref($inner_hash) && ref($inner_hash) eq "HASH" && !exists $inner_hash->{$vars[$_]} && $action eq 'optimize'; |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
18
|
0
|
0
|
0
|
|
|
|
if (looks_like_number($vars[$_]) && ref($inner_hash) && ref($inner_hash) eq "ARRAY") { |
|
|
|
0
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
$inner_hash->[$vars[$_]] = {} if !defined $inner_hash->[$vars[$_]]; |
20
|
0
|
|
|
|
|
|
$inner_hash = $inner_hash->[$vars[$_]]; |
21
|
|
|
|
|
|
|
} else { |
22
|
0
|
0
|
|
|
|
|
$inner_hash->{$vars[$_]} = {} if !exists $inner_hash->{$vars[$_]}; |
23
|
0
|
|
|
|
|
|
$inner_hash = $inner_hash->{$vars[$_]}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $result = $self->{contents}->$action($pipeline, $hash); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
return $self unless $self->is_processed($result); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# For now, only do renders. |
32
|
0
|
0
|
|
|
|
|
if ($action eq "optimize") { |
33
|
0
|
|
|
|
|
|
$pipeline->flag_conditional_uncertainty(\@vars); |
34
|
0
|
|
|
|
|
|
$inner_hash->{$vars[-1]} = $result; |
35
|
0
|
0
|
0
|
|
|
|
return undef if $pipeline->remove_assignment && !defined $pipeline->conditional_state; |
36
|
0
|
|
|
|
|
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
0
|
0
|
0
|
|
|
|
if (looks_like_number($vars[-1]) && ref($inner_hash) && ref($inner_hash) eq "ARRAY") { |
|
|
|
0
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$inner_hash->[$vars[-1]] = $result; |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
|
$inner_hash->{$vars[-1]} = $result; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
return ''; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub verify { |
47
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires a variable to be the capture target.") unless |
49
|
0
|
0
|
|
|
|
|
$self->{arguments}->[0]->isa('WWW::Shopify::Liquid::Token::Variable'); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |