OSDN Git Service

Plugin::TT2Renderer: fix code indent
authorhylom <hylom@users.sourceforge.jp>
Thu, 8 Sep 2016 09:57:48 +0000 (18:57 +0900)
committerhylom <hylom@users.sourceforge.jp>
Thu, 8 Sep 2016 09:57:48 +0000 (18:57 +0900)
dev/newslash_web/lib/Newslash/Plugin/TT2Renderer.pm

index 249ef21..048a951 100644 (file)
@@ -19,89 +19,89 @@ use FileHandle;
 
 # subclass for customizing template-provider
 {
-    package Newslash::Plugin::TT2Renderer::Provider;
-    use base qw(Template::Provider);
-
-    my $EXT = ["", ".html.tt2", ".tt2"];
-
-    sub _find_template {
-       my ($self, $fname) = @_;
-       foreach my $ext (@$EXT) {
-           my $path = $fname . $ext;
-           if (-f $path) {
-               return $path;
-           }
-       }
-       return undef;
+  package Newslash::Plugin::TT2Renderer::Provider;
+  use base qw(Template::Provider);
+
+  my $EXT = ["", ".html.tt2", ".tt2"];
+
+  sub _find_template {
+    my ($self, $fname) = @_;
+    foreach my $ext (@$EXT) {
+      my $path = $fname . $ext;
+      if (-f $path) {
+       return $path;
+      }
     }
-    
-    sub _template_modified {
-       my ($self, $fname) = @_;
-       my $path = $self->_find_template($fname);
-       if (!$path) {
-           return undef;
-       }
-       
-       return (stat($path))[9];
+    return undef;
+  }
+
+  sub _template_modified {
+    my ($self, $fname) = @_;
+    my $path = $self->_find_template($fname);
+    if (!$path) {
+      return undef;
     }
-    
-    sub _template_content {
-       my ($self, $fname) = @_;
-       my $path = $self->_find_template($fname);
-       if (!$path) {
-           return undef;
-       }
-       my $fh = FileHandle->new;
-       if ($fh->open($path, "r")) {
-           my $tmpl = do { local $/; <$fh> };
-           $fh->close;
-           return $tmpl;
-       }
-       return undef;
+
+    return (stat($path))[9];
+  }
+
+  sub _template_content {
+    my ($self, $fname) = @_;
+    my $path = $self->_find_template($fname);
+    if (!$path) {
+      return undef;
+    }
+    my $fh = FileHandle->new;
+    if ($fh->open($path, "r")) {
+      my $tmpl = do { local $/; <$fh> };
+      $fh->close;
+      return $tmpl;
     }
+    return undef;
+  }
 }
 
 sub register {
-    my ($self, $app, $conf) = @_;
-
-    $app->renderer->add_handler( 'tt2' => sub {
-        my ($renderer, $c, $output, $options) = @_;
-
-        my $inline_template = $options->{inline};
-        my $template_path = $renderer->template_path($options);
-        my $data_template = $renderer->get_data_template($options);
-       my $template_name = $renderer->template_name($options);
-       my $paths = $renderer->paths;
-
-        my $tt_options = $options || {};
-       $tt_options->{INCLUDE_PATH} = $paths;
-       $tt_options->{ENCODING} = 'utf8';
-       $tt_options->{LOAD_TEMPLATES} = [Newslash::Plugin::TT2Renderer::Provider->new($tt_options),];
-
-       #$log->debug(Dumper($tt_options));
-
-        my $tt = Template->new($tt_options);
-
-        my $template = '';
-        if ($inline_template) {
-            # use string as a template
-            $template = $inline_template;
-        } elsif ($data_template) {
-            # use template in DATA sections
-            $template = $data_template;
-        } else {
-            # read from file
-            $template = $template_name;
-        }
-        my $vars = $c->stash;
-        my $process_opts = {};
-
-        my $result = $tt->process($template, $vars, $output, $process_opts);
-        if (!$result) {
-            die $tt->error();
-        }
-       return $$output;
-                                 });
+  my ($self, $app, $conf) = @_;
+
+  $app->renderer->add_handler( 'tt2' => sub {
+                                my ($renderer, $c, $output, $options) = @_;
+
+                                my $inline_template = $options->{inline};
+                                my $template_path = $renderer->template_path($options);
+                                my $data_template = $renderer->get_data_template($options);
+                                my $template_name = $renderer->template_name($options);
+                                my $paths = $renderer->paths;
+
+                                my $tt_options = $options || {};
+                                $tt_options->{INCLUDE_PATH} = $paths;
+                                $tt_options->{ENCODING} = 'utf8';
+                                $tt_options->{LOAD_TEMPLATES} = [Newslash::Plugin::TT2Renderer::Provider->new($tt_options),];
+
+                                #$log->debug(Dumper($tt_options));
+
+                                my $tt = Template->new($tt_options);
+
+                                my $template = '';
+                                if ($inline_template) {
+                                  # use string as a template
+                                  $template = $inline_template;
+                                } elsif ($data_template) {
+                                  # use template in DATA sections
+                                  $template = $data_template;
+                                } else {
+                                  # read from file
+                                  $template = $template_name;
+                                }
+                                my $vars = $c->stash;
+                                my $process_opts = {};
+
+                                my $result = $tt->process($template, $vars, $output, $process_opts);
+                                if (!$result) {
+                                  die $tt->error();
+                                }
+                                return $$output;
+                              });
 }
 
 1;