Index: lang/perl/Jipotter/branches/Cipotter/lib/Cipotter/View/HTML.pm
===================================================================
--- lang/perl/Jipotter/branches/Cipotter/lib/Cipotter/View/HTML.pm (revision 9886)
+++ lang/perl/Jipotter/branches/Cipotter/lib/Cipotter/View/HTML.pm (revision 9886)
@@ -0,0 +1,65 @@
+package Cipotter::View::HTML;
+
+use strict;
+use warnings;
+use parent qw( Catalyst::View );
+use Template::Declare;
+use Module::Find;
+use Encode;
+
+my $init;
+
+BEGIN {
+  unless ( $init++ ) {
+    my @roots = useall 'Cipotter::Template';
+    Template::Declare->init( roots => \@roots );
+  }
+}
+
+__PACKAGE__->mk_classdata( wrapper => 'layout' );
+
+sub process {
+  my ($self, $c) = @_;
+
+  my $template = $c->stash->{template} or die 'specify template';
+  my $stash    = $c->stash->{data} || {};
+
+  my $uri = $c->request->uri->clone;
+  $stash->{base_path} = $c->stash->{base_path};
+  $stash->{uri} = $uri;
+  $stash->{uri_for} = sub {
+    my ($path, %params) = @_;
+    my $clone = $uri->clone;
+    if ( $defined $path ) {
+      if ( $path =~ /\?/ ) {
+        $clone->path_query($path);
+      }
+      else {
+        $clone->path($path)
+      }
+    }
+    $clone->query_param(%params) if %params;
+    return $clone->path_query;
+  };
+
+  my $html = encode_utf8( $self->render( $template, $stash ) );
+
+  $c->response->content_type('text/html; charset=utf-8');
+  $c->response->content_length( bytes::length( $html ) );
+  $c->response->body( $html );
+}
+
+sub render {
+  my ($self, $template, $stash) = @_;
+
+  my $wrapper = $self->wrapper || 'layout';
+  Template::Declare->new_buffer_frame;
+  my $html = Template::Declare->show( $wrapper, $template, $stash );
+  Template::Declare->end_buffer_frame;
+
+  $html =~ s/^\n+//;
+
+  return $html;
+}
+
+1;
