aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
index cbb68df0d..61d7c6ca5 100644
--- a/perllib/FixMyStreet/App/View/Web.pm
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -17,6 +17,7 @@ __PACKAGE__->config(
render_die => 1,
expose_methods => [
'loc', 'nget', 'tprintf', 'display_crossell_advert', 'prettify_epoch',
+ 'split_into_lines',
],
);
@@ -105,5 +106,28 @@ sub prettify_epoch {
return Page::prettify_epoch( $c->req, $epoch, $short_bool );
}
+=head2 split_into_lines
+
+ [% FOREACH line IN split_into_lines( text ) %]
+ <p>
+ [% line | html %]
+ </p>
+ [% END %]
+
+Split some text into an array of lines on double new lines.
+
+=cut
+
+sub split_into_lines {
+ my ( $self, $c, $text ) = @_;
+
+ my @lines;
+ $text =~ s/\r//g;
+
+ @lines = split /\n{2,}/, $text;
+
+ return \@lines;
+}
+
1;