package Template::Semantic::Filter; use strict; use warnings; use base 'Exporter'; our @EXPORT_OK = qw( chomp trim sort uniq comma html_line_break ); sub chomp { chomp; $_; } sub trim { s/^ *| *$//g; $_; } sub sort { join " ", sort split /\s+/; } sub uniq { my %h; join " ", map { $h{$_}++ == 0 ? $_ : () } split /\s+/; } sub comma { 1 while s/((?:\A|[^.0-9])[-+]?\d+)(\d{3})/$1,$2/s; $_; } sub html_line_break { s!(\r?\n)!
$1!g; \$_; } 1; __END__ =head1 NAME Template::Semantic::Filter - Template::Semantic Defined filters =head1 FILTERS =head2 chomp $ts->process($template, { 'h1' => [ "foo\n", 'chomp' ], # =>

foo

}) =head2 trim $ts->process($template, { 'h1' => [ " foo ", 'trim' ], # =>

foo

}) =head2 sort $ts->process($template, { 'h1@class' => [ "zzz xxx yyy", 'sort' ], # =>

foo

}) =head2 uniq $ts->process($template, { 'h1@chass' => [ "foo bar foo", 'uniq' ], # =>

foo

}) =head2 comma $ts->process($template, { 'h1' => [ "10000", 'comma' ], # =>

10,000

}) codes from: L. =head2 html_line_break $ts->process($template, { 'p' => [ "foo & foo\nbar\n", 'html_line_break' ], # => #

foo & foo
# bar

}) codes from: LC<::html_line_break()>. =head1 SEE ALSO L =head1 AUTHOR Naoki Tomita Etomita@cpan.orgE =cut