line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::Widthratio; |
2
|
2
|
|
|
2
|
|
764
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
52
|
|
3
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
40
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
30
|
use parent 'DTL::Fast::Tag::Simple'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{widthratio} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
88
|
use DTL::Fast::Utils; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
456
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#@Override |
12
|
|
|
|
|
|
|
sub parse_parameters |
13
|
|
|
|
|
|
|
{ |
14
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
3
|
50
|
|
|
|
22
|
if ($self->{parameter} =~ /^\s*(.+?)(?:\s+as\s+([^\s]+))?\s*$/s) |
17
|
|
|
|
|
|
|
{ |
18
|
3
|
|
|
|
|
9
|
$self->{target_name} = $2; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
13
|
$self->{sources} = $self->parse_sources($1); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
die $self->get_parse_error( |
23
|
|
|
|
|
|
|
sprintf( |
24
|
|
|
|
|
|
|
"Three arguments should be passed to widthratio: %s %s" |
25
|
|
|
|
|
|
|
, $self->{parameter} // 'undef' |
26
|
0
|
|
|
|
|
0
|
, scalar @{$self->{sources}} |
27
|
|
|
|
|
|
|
) |
28
|
3
|
50
|
0
|
|
|
5
|
) if (scalar @{$self->{sources}} != 3); |
|
3
|
|
|
|
|
9
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
|
|
0
|
die die $self->get_parse_error("Unable to parse ratio parameters $self->{parameter}"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
8
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#@Override |
39
|
|
|
|
|
|
|
sub render |
40
|
|
|
|
|
|
|
{ |
41
|
3
|
|
|
3
|
0
|
4
|
my $self = shift; |
42
|
3
|
|
|
|
|
6
|
my $context = shift; |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
6
|
my $sources = $self->{sources}; |
45
|
3
|
|
|
|
|
11
|
my $result = int( |
46
|
|
|
|
|
|
|
$sources->[0]->render($context) |
47
|
|
|
|
|
|
|
/ $sources->[1]->render($context) |
48
|
|
|
|
|
|
|
* $sources->[2]->render($context) |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
3
|
100
|
|
|
|
9
|
if ($self->{target_name}) |
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
|
|
5
|
$context->set($self->{target_name} => $result); |
54
|
1
|
|
|
|
|
1
|
$result = ''; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
11
|
return $result; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |