Permalink
Browse files

PodWeaver; some doc for Renderer::TTiny

  • Loading branch information...
1 parent 4bb1b06 commit e6e11396ca93a6dd075997525367b069809f0499 Zbigniew Lukasiak committed Sep 12, 2010
Showing with 51 additions and 23 deletions.
  1. +1 −1 dist.ini
  2. +1 −12 lib/WebNano.pm
  3. +0 −4 lib/WebNano/Controller.pm
  4. +49 −6 lib/WebNano/Renderer/TTiny.pm
View
@@ -20,4 +20,4 @@ repository.type = git
[PodSyntaxTests]
[PodCoverageTests]
[KwaliteeTests]
-
+[PodWeaver]
View
@@ -58,13 +58,7 @@ sub handle {
__END__
-=head1 NAME
-
-WebNano - A minimalistic PSGI based web framework
-
-=head1 VERSION
-
-This document describes WebNano version 0.001
+# ABSTRACT: A minimalistic PSGI based web framework.
=head1 SYNOPSIS
@@ -242,9 +236,4 @@ C<bug-webnano@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
-=head1 AUTHOR
-
-Zbigniew Lukasiak C<< <zby@cpan.org> >>
-
-
@@ -82,10 +82,6 @@ sub handle {
__END__
-=head1 NAME
-
-WebNano::Controller
-
=head1 SYNOPSIS
With Moose:
@@ -90,21 +90,63 @@ sub render {
__END__
-=head1 NAME
-
-WebNano::Renderer::TTiny - Template::Tiny renderer for WebNano
+# ABSTRACT: Dynamic search paths for Template::Tiny
=head1 SYNOPSIS
-see t/renderer.t
+in MyApp.pm:
+
+ $self->renderer(
+ WebNano::Renderer::TTiny->new( root => 't/data/templates' )
+ );
+
+in MyApp::Controller:
+
+ return $self->render( template => 'some_template.tt', some_var => 'some_value );
+
+=head1 DESCRIPTION
+
+This is a wrapper around
+L<Template::Tiny|http://search.cpan.org/~adamk/Template-Tiny/lib/Template/Tiny.pm>
+- 'Template Toolkit reimplemented in as little code as possible'.
+
+The only public method here is render - it expects as input a hash with the
+following data:
+
+=over
+
+=item template - the name of the template file
+
+=item c - the controller
+
+=back
+
+The template is then looked for in the directories in C<INCLUDE_PATH> and in
+directories constructed dynamically from the paths in C<root> and the controller
+name. For example if 'root' contains C<[ 'template', 'additional_templates' ]>
+and the controller name is C<MyApp::Controller::SubController> then the template
+will be looked for in C<template/SubController> and
+C<additional_templates/SubController>. This mechanism is designed so that it is
+possible for a way of subclassing templates along with subclassing controllers.
+If this is too complicated - you can provide no value for the C<root> attribute
+and use only C<INCLUDE_PATH>.
+
+When the template is found - the C<process> method on the internal
+C<Template::Tiny> object is called. A reference to the whole hash passed to
+C<render> is passed to the C<process> call - so that all the values are
+available in the template itself.
+
+If no template name is passed - then it is guessed from the name of the
+controller method that called C<render> (this is done using L<caller>) and the
+C<TEMPLATE_EXTENSION> attribute.
=head1 ATTRIBUTES and METHODS
=head2 render
=head2 INCLUDE_PATH
-Global list of template search directories.
+Static list of template search directories.
=head2 root
@@ -115,5 +157,6 @@ You can use INCLUDE_PATH or root or both.
=head2 TEMPLATE_EXTENSION
-Postfix added to action name to form the template name ( for example 'edit.tt' from 'edit' + '.tt' ).
+Postfix added to action name to form the template name ( for example 'edit.tt'
+from action 'edit' and TEMPLATE_EXTENSION 'tt' ).

0 comments on commit e6e1139

Please sign in to comment.