You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/11/29 01:48:30 UTC

[lucy-commits] svn commit: r1039997 - /incubator/lucy/site/trunk/lib/view.pm

Author: marvin
Date: Mon Nov 29 00:48:30 2010
New Revision: 1039997

URL: http://svn.apache.org/viewvc?rev=1039997&view=rev
Log:
Revert to using "read_text_file" from ASF::Util instead of _slurp_file.
Although the name doesn't imply it, read_text_file extracts header data -- and
that convention is used in many places throughout the CMS.

Modified:
    incubator/lucy/site/trunk/lib/view.pm

Modified: incubator/lucy/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/site/trunk/lib/view.pm?rev=1039997&r1=1039996&r2=1039997&view=diff
==============================================================================
--- incubator/lucy/site/trunk/lib/view.pm (original)
+++ incubator/lucy/site/trunk/lib/view.pm Mon Nov 29 00:48:30 2010
@@ -34,6 +34,7 @@ use warnings;
 use Carp;
 use Dotiac::DTL;
 use Dotiac::DTL::Addon::markup;
+use ASF::Util qw( read_text_file );
 
 BEGIN { push @Dotiac::DTL::TEMPLATE_DIRS, "templates"; }
 
@@ -41,11 +42,11 @@ BEGIN { push @Dotiac::DTL::TEMPLATE_DIRS
 
 sub basic {
     my %args = @_;
-    my $filepath      = "content$args{path}";
-    my $template_path = "templates/$args{template}";
+    my $filepath = "content$args{path}";
+    read_text_file($filepath, \%args);
     $args{path} =~ s/\.mdtext$/\.html/;
     $args{breadcrumbs} = _breadcrumbs($args{path});
-    $args{content}     = _slurp_file($filepath);
+    my $template_path = "templates/$args{template}";
     my $rendered = Dotiac::DTL->new($template_path)->render(\%args);
     return ($rendered, 'html', \%args);
 }
@@ -107,13 +108,6 @@ sub _breadcrumbs {
     return join " &raquo ", @rv;
 }
 
-sub _slurp_file {
-    my $path = shift;
-    open( my $fh, '<', $path ) or confess "Can't open '$path': $!";
-    local $/;
-    return <$fh>;
-}
-
 1;
 
 __END__