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 | 1232 | use strict; use utf8; use warnings FATAL => 'all'; | |||
2 | 2 | 3 | |||||
2 | 2 | 48 | |||||
2 | 10 | ||||||
2 | 3 | ||||||
2 | 13 | ||||||
2 | 48 | ||||||
2 | 4 | ||||||
2 | 70 | ||||||
3 | 2 | 2 | 10 | use parent 'DTL::Fast::Filter'; | |||
2 | 4 | ||||||
2 | 13 | ||||||
4 | |||||||
5 | $DTL::Fast::FILTER_HANDLERS{'linebreaks'} = __PACKAGE__; | ||||||
6 | |||||||
7 | #@Override | ||||||
8 | sub filter | ||||||
9 | { | ||||||
10 | 1 | 1 | 0 | 1 | shift; # self | ||
11 | 1 | 2 | my $filter_manager = shift; # filter_manager | ||||
12 | 1 | 2 | my $value = shift; # value | ||||
13 | 1 | 2 | shift; # context | ||||
14 | |||||||
15 | 1 | 1 | $filter_manager->{'safe'} = 1; | ||||
16 | 1 | 10 | $value =~ s/(^\s+|\s+$)//gs; | ||||
17 | 1 | 5 | $value =~ s/\n\n+/<\/p>\n /gs; |
||||
18 | 1 | 7 | $value =~ s/(?)\n/ \n/gsi; |
||||
19 | 1 | 50 | 9 | $value = " $value " if $value; |
|||
20 | |||||||
21 | 1 | 5 | return $value; | ||||
22 | } | ||||||
23 | |||||||
24 | 1; |