From 5267ab753868fc66de6e636dfc5be3c7eea1f3f0 Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Thu, 8 Aug 2013 09:11:04 -0400 Subject: [PATCH] more doco improvements --- README.pod | 137 +++++++++++++++------------ lib/Mojolicious/Plugin/TtRenderer.pm | 41 +++++--- 2 files changed, 100 insertions(+), 78 deletions(-) diff --git a/README.pod b/README.pod index 9363620..976af71 100644 --- a/README.pod +++ b/README.pod @@ -10,64 +10,13 @@ version 1.47 =head1 SYNOPSIS -L example: +L: - use Mojolicious::Lite; - plugin 'tt_renderer'; - - get '/' => sub { - my $self = shift; - $self->render('index'); - }; - - app->start; - - __DATA__ - - @@ index.html.tt - [% - WRAPPER 'layouts/default.html.tt' - title = 'Welcome' - %] -

Welcome to the Mojolicious real-time web framework!

-

Welcome to the TtRenderer plugin!

- [% END %] - - @@ layouts/default.html.tt - - - [% title %] - [% content %] - -L example: +L - package MyApp; - use Mojo::Base 'Mojolicious'; - - sub startup { - my $self = shift; - $self->plugin('tt_renderer'); - my $r = $self->routes; - $r->get('/')->to('example#welcome'); - } - - 1; - - package MyApp::Example; - use Mojo::Base 'Mojolicious::Controller'; - - # This action will render a template - sub welcome { - my $self = shift; - - # Render template "example/welcome.html.tt" with message - $self->render( - message => 'Looks like your TtRenderer is working!'); - } - - 1; + $self->plugin('tt_renderer'); =head1 DESCRIPTION @@ -162,22 +111,84 @@ is equivalent to except in the first example relative paths are relative to the L app's home directory (C<$app->home>). -=head1 METHODS +=head1 STASH -L inherits all methods from -L and implements the following new ones. +=head2 h -=head2 C +Helpers are available via the C entry in the stash. - $plugin->register; + go back to index -Register renderer in L application. - -=head1 EXTRA STASH VARIABLES +=head2 c The current controller instance can be accessed as C. - [% c.req.headers.host %] + I see you are requesting a document from [% c.req.headers.host %]. + +=head1 EXAMPLES + +L example: + + use Mojolicious::Lite; + + plugin 'tt_renderer'; + + get '/' => sub { + my $self = shift; + $self->render('index'); + }; + + app->start; + + __DATA__ + + @@ index.html.tt + [% + WRAPPER 'layouts/default.html.tt' + title = 'Welcome' + %] +

Welcome to the Mojolicious real-time web framework!

+

Welcome to the TtRenderer plugin!

+ [% END %] + + @@ layouts/default.html.tt + + + [% title %] + [% content %] + + +L example: + + package MyApp; + use Mojo::Base 'Mojolicious'; + + sub startup { + my $self = shift; + $self->plugin('tt_renderer'); + my $r = $self->routes; + $r->get('/')->to('example#welcome'); + } + + 1; + + package MyApp::Example; + use Mojo::Base 'Mojolicious::Controller'; + + # This action will render a template + sub welcome { + my $self = shift; + + # Render template "example/welcome.html.tt" with message + $self->render( + message => 'Looks like your TtRenderer is working!'); + } + + 1; + +These are also included with the C +distribution, including the support files required for the full +L app example. =head1 SEE ALSO diff --git a/lib/Mojolicious/Plugin/TtRenderer.pm b/lib/Mojolicious/Plugin/TtRenderer.pm index b558452..b17791d 100644 --- a/lib/Mojolicious/Plugin/TtRenderer.pm +++ b/lib/Mojolicious/Plugin/TtRenderer.pm @@ -31,15 +31,13 @@ __END__ =head1 SYNOPSIS -L example: +L: -# EXAMPLE: example/myapp.pl + plugin 'tt_renderer'; -L example: +L -# EXAMPLE: example/myapp/lib/MyApp.pm - -# EXAMPLE: example/myapp/lib/MyApp/Example.pm + $self->plugin('tt_renderer'); =head1 DESCRIPTION @@ -132,22 +130,35 @@ is equivalent to except in the first example relative paths are relative to the L app's home directory (C<$app->home>). -=head1 METHODS +=head1 STASH -L inherits all methods from -L and implements the following new ones. +=head2 h -=head2 C +Helpers are available via the C entry in the stash. - $plugin->register; + go back to index -Register renderer in L application. - -=head1 EXTRA STASH VARIABLES +=head2 c The current controller instance can be accessed as C. - [% c.req.headers.host %] + I see you are requesting a document from [% c.req.headers.host %]. + +=head1 EXAMPLES + +L example: + +# EXAMPLE: example/myapp.pl + +L example: + +# EXAMPLE: example/myapp/lib/MyApp.pm + +# EXAMPLE: example/myapp/lib/MyApp/Example.pm + +These are also included with the C +distribution, including the support files required for the full +L app example. =head1 SEE ALSO