App-Templer
view release on metacpan or search on metacpan
lib/Templer/Global.pm view on Meta::CPAN
#
# If the configuration file doesn't exist that's a shame.
#
return if ( !-e $filename );
#
# Open the file, making sure we're UTF-8 safe.
#
open( my $handle, "<:utf8", $filename ) or
die "Failed to read '$filename' - $!";
binmode( $handle, ":utf8" );
while ( my $line = <$handle> )
{
# strip trailing newline.
$line =~ s/[\r\n]*//g;
# skip comments.
next if ( $line =~ /^#/ );
lib/Templer/Plugin/FileContents.pm view on Meta::CPAN
{
my ( $self, $name ) = (@_);
my $content = "";
if ( -e $name )
{
open( my $handle, "<:utf8", $name ) or
return "";
binmode( $handle, ":utf8" );
while ( my $line = <$handle> )
{
$content .= $line;
}
close($handle);
}
else
{
print "WARNING: Attempting to read a file that doesn't exist: $name\n";
lib/Templer/Plugin/FileGlob.pm view on Meta::CPAN
}
}
else
{
#
# If it isn't an image we'll make the content available
#
if ( open( my $handle, "<:utf8", $file ) )
{
binmode( $handle, ":utf8" );
while ( my $line = <$handle> )
{
$meta{ 'contents' } .= $line;
}
close($handle);
}
}
push( @$ref, \%meta );
}
lib/Templer/Site.pm view on Meta::CPAN
{
$path = $1;
File::Path::mkpath( $path, { verbose => 0, mode => oct(755) } )
if ( !-d $path );
}
#
# Output the expanded template to the destination file.
#
open my $handle, ">:utf8", $dst or die "Failed to write to '$dst' - $!";
binmode( $handle, ":utf8" );
print $handle $tmpl->output();
close $handle;
}
#
# Cleanup any plugins.
#
$PLUGINS->cleanup();
#
lib/Templer/Site/Page.pm view on Meta::CPAN
This is an internal method.
=cut
sub _parse_page
{
my ( $self, $filename ) = (@_);
open( my $handle, "<:utf8", $filename ) or
die "Failed to read '$filename' - $!";
binmode( $handle, ":utf8" );
my $header = 1;
while ( my $line = <$handle> )
{
# strip trailing newline.
$line =~ s/[\r\n]*//g;
if ($header)
( run in 0.661 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )