App-Dapper
view release on metacpan or search on metacpan
`sqrt` | Returns the square root of the number.
`srand` | Calls the perl srand function to set the internal random seed. This will affect future calls to the rand vmethod.
`stderr` | Print the item to the current STDERR handle.
`substr(i, n)` | Returns a substring of item starting at `i` and going to the end of the string. If `n` is passed, the substring stops after `n` characters.
`trim` | Strips leading and trailing whitespace.
`uc` | Same as the upper command. Returns uppercased string.
`ucfirst` | Uppercase the leading letter.
`upper` | Return the string uppercased.
`uri` | Perform a very basic URI encoding.
`url` | Perform a URI encoding - but some characters such as `:` and `/` are left intact.
`xml_escape` | [DSF] Escape strings that may contain XML so the string can be included in XML files such as ATOM or RSS feeds
`xml` | Performs a very basic xml encoding (swaps out `&`, `<`, `>`, `'` and `"` with the corresponding xml entities).
*List*
The following methods can be called on arrays (text/strings are automatically
converted to an array containing a single element containing the value of the
text/string).
Filter | Description
---------------------|-----------------------------------------------------------------------
lib/App/Dapper.pm view on Meta::CPAN
sub render {
my ($self) = @_;
my $tt = Template::Alloy->new({
INCLUDE_PATH => $self->{layout},
ANYCASE => 1,
ENCODING => 'utf8',
#STRICT => 1,
FILTERS => {
'xml_escape' => \&App::Dapper::Filters::xml_escape,
'date_to_xmlschema' => \&App::Dapper::Filters::date_to_xmlschema,
'replace_last' => \&App::Dapper::Filters::replace_last,
'smart' => \&App::Dapper::Filters::smart,
'json' => \&App::Dapper::Filters::json,
},
#ERROR => 'alloy_errors.html',
EVAL_PERL => $ENV{EVAL_PERL} || 0,
#DEBUG => DEBUG_ALL,
}) || die "$Template::ERROR\n";
lib/App/Dapper/Filters.pm view on Meta::CPAN
=cut
use utf8;
use open ':std', ':encoding(UTF-8)';
use 5.8.0;
use strict;
use warnings FATAL => 'all';
use Data::Dumper;
use CGI qw(:standard escapeHTML);
=head2 import
Called when this module is 'used' from somewhere else. This subroutine
registers Liquid filters contained in this file.
=cut
#sub import {
# $filters = Template::Filters->new({
# FILTERS => {
# 'xml_escape' => \&xml_escape,
# 'date_to_xmlschema' => \&date_to_xmlschema,
# 'replace_last' => \&replace_last,
# 'smart' => \&smart,
# 'json' => \&json,
# },
# });
#}
=head2 xml_escape
Liquid filter to escape strings into formats that can be included
in XML files.
=cut
sub xml_escape {
my $str = shift;
my $q = new CGI;
return $q->escapeHTML( $str );
}
=head2 date_to_xmlschema
Convert a date to an XML-formattted version of the date that also includes
the timezone.
=cut
sub date_to_xmlschema {
( run in 0.449 second using v1.01-cache-2.11-cpan-c21f80fb71c )