
CGI::AppToolkit::Template::Filter - A superclass for CGI::AppToolkit::Template filters

CGI::AppToolkit::Template::Filter is intended for subclassing and overriding it's filter() method.
filter() is called as an object with two parameters.
The first parameter (after the object reference) is a hashref of the arguments specified in the calling template.
The second parameter is the value to be 'filtered.'
In addition to being able to write your own filters easily,
CGI::AppToolkit comes with several filters:
<BR> tags (or the first parameter passed) to the end of every line.+) instead of %20.sprintf() format.
It defaults to %.2f.
(NOTE: This can be used as a general sprintf() filter.)abs() in the given number,
making it positive.
If the first parameter is true,
then it makes it negative.
This is the complete code of CGI::AppToolkit::Template::Filter::BR.
package CGI::AppToolkit::Template::Filter::BR;
$VERSION = '0.05';
require 5.004;
use Carp;
use base 'CGI::AppToolkit::Template::Filter';
use strict;
sub filter {
my $self = shift;
my $args = shift;
my $text = shift;
my $br = ref $args && @$args ? $args->[0] : '<br>';
$text =~ s/(\r?\n)/$br\1/g;
$text
}
1;