line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
21
|
|
|
21
|
|
10630
|
use strict; |
|
21
|
|
|
|
|
38
|
|
|
21
|
|
|
|
|
738
|
|
3
|
21
|
|
|
21
|
|
103
|
use warnings; |
|
21
|
|
|
|
|
32
|
|
|
21
|
|
|
|
|
540
|
|
4
|
|
|
|
|
|
|
|
5
|
21
|
|
|
21
|
|
101
|
use WWW::Shopify::Liquid::Tag; |
|
21
|
|
|
|
|
32
|
|
|
21
|
|
|
|
|
688
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Tag::Assign; |
8
|
21
|
|
|
21
|
|
90
|
use base 'WWW::Shopify::Liquid::Tag::Free'; |
|
21
|
|
|
|
|
35
|
|
|
21
|
|
|
|
|
8401
|
|
9
|
0
|
|
|
0
|
0
|
0
|
sub min_arguments { return 1; } |
10
|
0
|
|
|
0
|
0
|
0
|
sub max_arguments { return 1; } |
11
|
|
|
|
|
|
|
sub verify { |
12
|
38
|
|
|
38
|
0
|
52
|
my ($self) = @_; |
13
|
38
|
50
|
|
|
|
241
|
die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires assignment operator to be the first thing in an assign tag.") unless |
14
|
|
|
|
|
|
|
$self->{arguments}->[0]->isa('WWW::Shopify::Liquid::Operator::Assignment'); |
15
|
38
|
50
|
|
|
|
218
|
die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, "Requires variable for what you're assigning to.") unless |
16
|
|
|
|
|
|
|
$self->{arguments}->[0]->{operands}->[0]->isa('WWW::Shopify::Liquid::Token::Variable'); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
sub process { |
19
|
11
|
|
|
11
|
0
|
16
|
my ($self, $hash, $action) = @_; |
20
|
11
|
50
|
|
|
|
16
|
my @vars = map { $self->is_processed($_) ? $_ : $_->process($hash, $action) } @{$self->{arguments}->[0]->{operands}->[0]->{core}}; |
|
11
|
|
|
|
|
40
|
|
|
11
|
|
|
|
|
37
|
|
21
|
11
|
50
|
33
|
|
|
34
|
return $self if $action eq "optimize" && int(grep { !$self->is_processed($_) } @vars) > 0; |
|
0
|
|
|
|
|
0
|
|
22
|
11
|
|
|
|
|
14
|
my $inner_hash = $hash; |
23
|
11
|
|
|
|
|
31
|
for (0..$#vars-1) { |
24
|
0
|
0
|
0
|
|
|
0
|
return $self if !exists $inner_hash->{$vars[$_]} && $action eq 'optimize'; |
25
|
0
|
0
|
|
|
|
0
|
$inner_hash->{$vars[$_]} = {} if !exists $inner_hash->{$vars[$_]}; |
26
|
0
|
|
|
|
|
0
|
$inner_hash = $inner_hash->{$vars[$_]}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
# For now, only do renders. |
29
|
11
|
50
|
|
|
|
32
|
if ($action eq "optimize") { |
30
|
|
|
|
|
|
|
# If we run across something that should be assigned, we must delete it in the hash to preserve uncertainty. |
31
|
0
|
|
|
|
|
0
|
delete $inner_hash->{$vars[-1]}; |
32
|
0
|
|
|
|
|
0
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
11
|
|
|
|
|
63
|
my $result = $self->{arguments}->[0]->{operands}->[1]->$action($hash); |
35
|
11
|
50
|
|
|
|
29
|
return $self unless $self->is_processed($result); |
36
|
11
|
|
|
|
|
37
|
$inner_hash->{$vars[-1]} = $result; |
37
|
11
|
|
|
|
|
43
|
return ''; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |