line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::With; |
2
|
4
|
|
|
4
|
|
1231
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
101
|
|
3
|
4
|
|
|
4
|
|
19
|
use utf8; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
44
|
|
4
|
4
|
|
|
4
|
|
88
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
124
|
|
5
|
4
|
|
|
4
|
|
23
|
use parent 'DTL::Fast::Tag'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
19
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{with} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
35
|
|
|
35
|
0
|
100
|
sub get_close_tag {return 'endwith';} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#@Override |
13
|
|
|
|
|
|
|
sub parse_parameters |
14
|
|
|
|
|
|
|
{ |
15
|
23
|
|
|
23
|
0
|
44
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
23
|
|
|
|
|
50
|
$self->{mappings} = { }; |
18
|
23
|
100
|
|
|
|
92
|
if ($self->{parameter} =~ /^\s*(.+?)\s+as\s+(.+)\s*$/s) # legacy |
19
|
|
|
|
|
|
|
{ |
20
|
1
|
|
|
|
|
7
|
$self->{mappings}->{$2} = DTL::Fast::Expression->new($1); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else # modern |
23
|
|
|
|
|
|
|
{ |
24
|
22
|
|
|
|
|
45
|
my @parts = (); |
25
|
22
|
|
|
|
|
80
|
my $string = $self->backup_strings($self->{parameter}); |
26
|
|
|
|
|
|
|
|
27
|
22
|
|
|
|
|
140
|
while ( $string =~ s{^ |
28
|
|
|
|
|
|
|
\s* |
29
|
|
|
|
|
|
|
([^\s\=]+) |
30
|
|
|
|
|
|
|
\s*\=\s* |
31
|
|
|
|
|
|
|
([^\s\=]+) |
32
|
|
|
|
|
|
|
\s* |
33
|
|
|
|
|
|
|
}{}x |
34
|
|
|
|
|
|
|
) |
35
|
|
|
|
|
|
|
{ |
36
|
36
|
|
|
|
|
125
|
$self->{mappings}->{$1} = $self->get_backup_or_variable($2); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
21
|
100
|
|
|
|
67
|
if ($string) { |
40
|
|
|
|
|
|
|
die $self->get_parse_error( |
41
|
|
|
|
|
|
|
"there is an error in `with` parameters" |
42
|
|
|
|
|
|
|
, 'Passed parameters' => $self->{parameter} |
43
|
2
|
|
|
|
|
17
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
20
|
|
|
|
|
44
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#@Override |
51
|
|
|
|
|
|
|
sub render |
52
|
|
|
|
|
|
|
{ |
53
|
14
|
|
|
14
|
0
|
25
|
my $self = shift; |
54
|
14
|
|
|
|
|
23
|
my $context = shift; |
55
|
|
|
|
|
|
|
|
56
|
14
|
|
|
|
|
29
|
my %vars = (); |
57
|
14
|
|
|
|
|
23
|
foreach my $key (keys(%{$self->{mappings}})) |
|
14
|
|
|
|
|
43
|
|
58
|
|
|
|
|
|
|
{ |
59
|
24
|
|
|
|
|
102
|
$vars{$key} = $self->{mappings}->{$key}->render($context); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
14
|
|
|
|
|
46
|
$context->push_scope()->set(%vars); |
63
|
|
|
|
|
|
|
|
64
|
14
|
|
|
|
|
58
|
my $result = $self->SUPER::render($context); |
65
|
|
|
|
|
|
|
|
66
|
10
|
|
|
|
|
33
|
$context->pop_scope(); |
67
|
|
|
|
|
|
|
|
68
|
10
|
|
|
|
|
38
|
return $result; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |