| blib/lib/HTML/Template/Compiled/Plugin/LineBreak.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 14 | 15 | 93.3 |
| branch | 6 | 8 | 75.0 |
| condition | n/a | ||
| subroutine | 4 | 4 | 100.0 |
| pod | 0 | 2 | 0.0 |
| total | 24 | 29 | 82.7 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package HTML::Template::Compiled::Plugin::LineBreak; | ||||||
| 2 | |||||||
| 3 | # $Id: LineBreak.pm 25 2008-03-10 12:00:34Z hagy $ | ||||||
| 4 | |||||||
| 5 | 1 | 1 | 135222 | use strict; | |||
| 1 | 2 | ||||||
| 1 | 54 | ||||||
| 6 | 1 | 1 | 5 | use warnings; | |||
| 1 | 1 | ||||||
| 1 | 204 | ||||||
| 7 | our $VERSION = '0.02'; | ||||||
| 8 | |||||||
| 9 | HTML::Template::Compiled->register(__PACKAGE__); | ||||||
| 10 | |||||||
| 11 | sub register { | ||||||
| 12 | 1 | 1 | 0 | 11 | my ($class) = @_; | ||
| 13 | 1 | 5 | my %plugs = ( | ||||
| 14 | escape => { | ||||||
| 15 | LINEBREAK => \&html_line_break, | ||||||
| 16 | BR => \&html_line_break, | ||||||
| 17 | }, | ||||||
| 18 | ); | ||||||
| 19 | 1 | 3 | return \%plugs; | ||||
| 20 | } | ||||||
| 21 | |||||||
| 22 | sub html_line_break { | ||||||
| 23 | 5 | 5 | 0 | 7609 | local $_ = shift; | ||
| 24 | |||||||
| 25 | 5 | 50 | 14 | defined or return; | |||
| 26 | |||||||
| 27 | # s|(\r?\n)| $1|g; |
||||||
| 28 | 5 | 100 | 46 | s|\x0D\x0A| \r\n|g and return $_; # for \r\n CRLF WIN |
|||
| 29 | 4 | 100 | 43 | s|\x0D| \r|g and return $_; # for \r CR MAC |
|||
| 30 | 3 | 50 | 106 | s|\x0A| \n|g and return $_; # for \n LF UNIX |
|||
| 31 | 0 | return $_; | |||||
| 32 | } | ||||||
| 33 | |||||||
| 34 | 1; | ||||||
| 35 | __END__ |