blib/lib/DTL/Fast/Filter/Linebreaks.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 22 | 22 | 100.0 |
branch | 1 | 2 | 50.0 |
condition | n/a | ||
subroutine | 5 | 5 | 100.0 |
pod | 0 | 1 | 0.0 |
total | 28 | 30 | 93.3 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package DTL::Fast::Filter::Linebreaks; | ||||||
2 | 2 | 2 | 702 | use strict; | |||
2 | 4 | ||||||
2 | 45 | ||||||
3 | 2 | 2 | 9 | use utf8; | |||
2 | 33 | ||||||
2 | 9 | ||||||
4 | 2 | 2 | 46 | use warnings FATAL => 'all'; | |||
2 | 4 | ||||||
2 | 56 | ||||||
5 | 2 | 2 | 9 | use parent 'DTL::Fast::Filter'; | |||
2 | 3 | ||||||
2 | 9 | ||||||
6 | |||||||
7 | $DTL::Fast::FILTER_HANDLERS{linebreaks} = __PACKAGE__; | ||||||
8 | |||||||
9 | #@Override | ||||||
10 | sub filter | ||||||
11 | { | ||||||
12 | 1 | 1 | 0 | 2 | shift; # self | ||
13 | 1 | 2 | my $filter_manager = shift; # filter_manager | ||||
14 | 1 | 1 | my $value = shift; # value | ||||
15 | 1 | 2 | shift; # context | ||||
16 | |||||||
17 | 1 | 1 | $filter_manager->{safe} = 1; | ||||
18 | 1 | 9 | $value =~ s/(^\s+|\s+$)//gs; | ||||
19 | 1 | 4 | $value =~ s/\n\n+/<\/p>\n /gs; |
||||
20 | 1 | 6 | $value =~ s/(?)\n/ \n/gsi; |
||||
21 | 1 | 50 | 7 | $value = " $value " if ($value); |
|||
22 | |||||||
23 | 1 | 3 | return $value; | ||||
24 | } | ||||||
25 | |||||||
26 | 1; |