line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Creates a tag to be used in the system, much like a function call. Should probably disallow recursion in order to preserve the non-looping nature of liquid. |
2
|
|
|
|
|
|
|
|
3
|
37
|
|
|
37
|
|
31089
|
use strict; |
|
37
|
|
|
|
|
123
|
|
|
37
|
|
|
|
|
1176
|
|
4
|
37
|
|
|
37
|
|
245
|
use warnings; |
|
37
|
|
|
|
|
107
|
|
|
37
|
|
|
|
|
1673
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Tag::CustomTag; |
7
|
37
|
|
|
37
|
|
249
|
use parent 'WWW::Shopify::Liquid::Tag'; |
|
37
|
|
|
|
|
96
|
|
|
37
|
|
|
|
|
251
|
|
8
|
|
|
|
|
|
|
|
9
|
37
|
|
|
37
|
|
2685
|
use Scalar::Util qw(blessed); |
|
37
|
|
|
|
|
100
|
|
|
37
|
|
|
|
|
22181
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
15
|
|
|
15
|
|
41
|
my ($package, $line, $tag, $arguments, $contents, $parser) = @_; |
13
|
15
|
100
|
|
|
|
34
|
if (!ref($package)) { |
14
|
6
|
|
|
|
|
13
|
my @arguments = @$arguments; |
15
|
6
|
|
|
|
|
13
|
my ($free) = grep { $_->{core} eq "free" } @arguments; |
|
10
|
|
|
|
|
29
|
|
16
|
6
|
100
|
|
|
|
30
|
my $self = bless { |
17
|
|
|
|
|
|
|
free => $free ? 1 : 0, |
18
|
|
|
|
|
|
|
name => $tag, |
19
|
|
|
|
|
|
|
contents => $contents |
20
|
|
|
|
|
|
|
}, $package; |
21
|
|
|
|
|
|
|
die new WWW::Shopify::Liquid::Exception("Cannot register custom tag " . $tag . ", would conflict with buildin tag.") if |
22
|
|
|
|
|
|
|
($parser->free_tags->{$tag} && !$parser->free_tags->{$tag}->isa('WWW::Shopify::Liquid::Tag::CustomTag')) || |
23
|
6
|
50
|
66
|
|
|
21
|
($parser->enclosing_tags->{$tag} && !$parser->enclosing_tags->{$tag}->isa('WWW::Shopify::Liquid::Tag::CustomTag')); |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
24
|
6
|
0
|
33
|
|
|
35
|
die new WWW::Shopify::Liquid::Exception("Recursion is disallowed in liquid.") unless int(grep { defined $_ && blessed($_) && $_->isa('WWW::Shopify::Liquid::Tag::CustomTag') && $tag && $_->name && $tag eq $_->name } $contents->tokens) == 0; |
|
9
|
50
|
33
|
|
|
104
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
25
|
6
|
100
|
|
|
|
21
|
push(@{$parser->{transient_elements}}, $self) if $parser->transient_custom_operations; |
|
3
|
|
|
|
|
8
|
|
26
|
6
|
|
|
|
|
17
|
$parser->custom_tags->{$self->name} = $self; |
27
|
6
|
|
|
|
|
37
|
return $self; |
28
|
|
|
|
|
|
|
} else { |
29
|
9
|
|
|
|
|
39
|
my $self = ref(shift)->SUPER::new(@_); |
30
|
9
|
|
|
|
|
29
|
$self->{stored_contents} = $self->{contents}->[0]->[0]; |
31
|
9
|
|
|
|
|
23
|
$self->{contents} = $parser->custom_tags->{$self->{core}}->{contents}; |
32
|
9
|
|
|
|
|
24
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
6
|
|
22
|
sub abstract { return !ref($_[0]); } |
37
|
2
|
|
|
2
|
|
12
|
sub inner_halt_lexing { return 0; } |
38
|
1
|
|
|
1
|
|
31
|
sub inner_ignore_whitespace { return 0; } |
39
|
6
|
100
|
|
6
|
|
28
|
sub is_free { return $_[0]->{free} ? 1 : 0; } |
40
|
15
|
100
|
|
15
|
|
67
|
sub is_enclosing { return !$_[0]->{free} ? 1 : 0; } |
41
|
0
|
|
|
0
|
|
0
|
sub tags { return $_[0]->{name}; } |
42
|
18
|
|
|
18
|
|
55
|
sub name { return $_[0]->{name}; } |
43
|
0
|
|
|
0
|
|
0
|
sub ast { return $_[0]->{ast}; } |
44
|
0
|
|
0
|
0
|
|
0
|
sub min_arguments { return $_[0]->{min_arguments} || 0; } |
45
|
0
|
|
|
0
|
|
0
|
sub max_arguments { return $_[0]->{max_arguments}; } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub optimize { |
48
|
0
|
|
|
0
|
|
0
|
return $_[0]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
37
|
|
|
37
|
|
324
|
use Scalar::Util qw(blessed); |
|
37
|
|
|
|
|
108
|
|
|
37
|
|
|
|
|
7010
|
|
52
|
|
|
|
|
|
|
sub render { |
53
|
8
|
|
|
8
|
|
21
|
my ($self, $renderer, $hash) = @_; |
54
|
8
|
|
|
|
|
12
|
my @arguments = map { $_->render($renderer, $hash) } @{$self->{arguments}}; |
|
0
|
|
|
|
|
0
|
|
|
8
|
|
|
|
|
23
|
|
55
|
8
|
|
|
|
|
18
|
$hash->{arguments} = \ @arguments; |
56
|
8
|
100
|
66
|
|
|
34
|
my $contents = $self->{stored_contents} && blessed($self->{stored_contents}) ? $self->{stored_contents}->render($renderer, $hash) : undef; |
57
|
8
|
|
|
|
|
18
|
$hash->{contents} = $contents; |
58
|
8
|
|
|
|
|
30
|
return $self->{contents}->render($renderer, $hash); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Tag::CreateTag; |
63
|
37
|
|
|
37
|
|
317
|
use parent 'WWW::Shopify::Liquid::Tag::Enclosing'; |
|
37
|
|
|
|
|
115
|
|
|
37
|
|
|
|
|
200
|
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
0
|
0
|
sub min_arguments { 2 } |
66
|
0
|
|
|
0
|
0
|
0
|
sub max_arguments { 4 } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
69
|
6
|
|
|
6
|
0
|
20
|
my ($package, $line, $tag, $arguments, $contents, $parser) = @_; |
70
|
6
|
|
|
|
|
25
|
my $self = $package->SUPER::new($line, $tag, $arguments, $contents, $parser); |
71
|
6
|
|
|
|
|
22
|
$parser->parent->register_tag(WWW::Shopify::Liquid::Tag::CustomTag->new([], $arguments->[0]->{core}, $arguments, @{$contents->[0]}, $parser)); |
|
6
|
|
|
|
|
22
|
|
72
|
6
|
|
|
|
|
19
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
3
|
0
|
7
|
sub render { '' } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |