Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f20c780b8 | ||
|
|
c7c249b51f | ||
|
|
dae8329981 | ||
|
|
5e650027c7 | ||
|
|
698fc48b58 | ||
|
|
49075ebe44 |
@@ -6,6 +6,7 @@ _build*
|
|||||||
pm_to_blib*
|
pm_to_blib*
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
.lwpcookies
|
.lwpcookies
|
||||||
|
Mojolicious-Plugin-TtRenderer-*
|
||||||
MojoX-Renderer-TT-*
|
MojoX-Renderer-TT-*
|
||||||
cover_db
|
cover_db
|
||||||
*~
|
*~
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
Revision history for MojoX-Renderer-TT
|
Revision history for MojoX-Renderer-TT
|
||||||
|
|
||||||
{{$NEXT}}
|
{{$NEXT}}
|
||||||
|
|
||||||
|
1.14 August 1, 2011
|
||||||
|
- Drop use of MojoX namespace for Mojolicious::Plugin::TtRenderer::
|
||||||
|
(GH#12, Cosimo Streppone)
|
||||||
|
|
||||||
|
1.13 June 7, 2011
|
||||||
|
- Compatibility with Mojolicious 1.3+
|
||||||
|
|
||||||
|
1.12 February 28, 2011
|
||||||
- Inline wrappers and includes now work on Windows
|
- Inline wrappers and includes now work on Windows
|
||||||
(GH#13, Christiaan Kras)
|
(GH#13, Christiaan Kras)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name = MojoX-Renderer-TT
|
name = Mojolicious-Plugin-TtRenderer
|
||||||
author = Ask Bjørn Hansen <ask@develooper.com>
|
author = Ask Bjørn Hansen <ask@develooper.com>
|
||||||
license = Perl_5
|
license = Perl_5
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ copyright_holder = Ask Bjørn Hansen
|
|||||||
# copyright_year = 2009
|
# copyright_year = 2009
|
||||||
|
|
||||||
[Prereqs]
|
[Prereqs]
|
||||||
Mojolicious = 1.01
|
Mojolicious = 1.3
|
||||||
Template = 2.18
|
Template = 2.18
|
||||||
|
|
||||||
[Prereqs / TestRequires ]
|
[Prereqs / TestRequires ]
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ our $VERSION = '0.01';
|
|||||||
|
|
||||||
use base 'Mojolicious::Plugin';
|
use base 'Mojolicious::Plugin';
|
||||||
|
|
||||||
use MojoX::Renderer::TT;
|
use Mojolicious::Plugin::TtRenderer::Engine;
|
||||||
|
|
||||||
sub register {
|
sub register {
|
||||||
my ($self, $app, $args) = @_;
|
my ($self, $app, $args) = @_;
|
||||||
|
|
||||||
$args ||= {};
|
$args ||= {};
|
||||||
|
|
||||||
my $tt = MojoX::Renderer::TT->build(%$args, app => $app);
|
my $tt = Mojolicious::Plugin::TtRenderer::Engine->build(%$args, app => $app);
|
||||||
|
|
||||||
# Add "tt" handler
|
# Add "tt" handler
|
||||||
$app->renderer->add_handler(tt => $tt);
|
$app->renderer->add_handler(tt => $tt);
|
||||||
@@ -54,6 +54,6 @@ Register renderer in L<Mojolicious> application.
|
|||||||
|
|
||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<MojoX::Renderer::TT>, L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.
|
L<Mojolicious::Plugin::TtRenderer::Engine>, L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package MojoX::Renderer::TT;
|
package Mojolicious::Plugin::TtRenderer::Engine;
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use base 'Mojo::Base';
|
use base 'Mojo::Base';
|
||||||
|
|
||||||
|
use Carp ();
|
||||||
use File::Spec ();
|
use File::Spec ();
|
||||||
use Mojo::ByteStream 'b';
|
use Mojo::ByteStream 'b';
|
||||||
use Template ();
|
use Template ();
|
||||||
@@ -43,7 +44,7 @@ sub _init {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$config{LOAD_TEMPLATES} =
|
$config{LOAD_TEMPLATES} =
|
||||||
[MojoX::Renderer::TT::Provider->new(%config, renderer => $app->renderer)]
|
[Mojolicious::Plugin::TtRenderer::Provider->new(%config, renderer => $app->renderer)]
|
||||||
unless $config{LOAD_TEMPLATES};
|
unless $config{LOAD_TEMPLATES};
|
||||||
|
|
||||||
$self->tt(Template->new(\%config))
|
$self->tt(Template->new(\%config))
|
||||||
@@ -64,7 +65,7 @@ sub _render {
|
|||||||
return unless $t;
|
return unless $t;
|
||||||
|
|
||||||
|
|
||||||
my $helper = MojoX::Renderer::TT::Helper->new(ctx => $c);
|
my $helper = Mojolicious::Plugin::TtRenderer::Helper->new(ctx => $c);
|
||||||
|
|
||||||
# Purge previous result
|
# Purge previous result
|
||||||
$$output = '';
|
$$output = '';
|
||||||
@@ -90,10 +91,10 @@ sub _render {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
1; # End of MojoX::Renderer::TT
|
1; # End of Mojolicious::Plugin::TtRenderer::Engine
|
||||||
|
|
||||||
package
|
package
|
||||||
MojoX::Renderer::TT::Helper;
|
Mojolicious::Plugin::TtRenderer::Helper;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -123,7 +124,7 @@ sub AUTOLOAD {
|
|||||||
1;
|
1;
|
||||||
|
|
||||||
package
|
package
|
||||||
MojoX::Renderer::TT::Provider;
|
Mojolicious::Plugin::TtRenderer::Provider;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -159,7 +160,7 @@ sub _template_content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Try DATA section
|
# Try DATA section
|
||||||
elsif (my $d = $self->renderer->get_inline_template($self->ctx, $t)) {
|
elsif (my $d = $self->renderer->get_data_template($self->ctx, $t)) {
|
||||||
return wantarray ? ($d, '', time) : $d;
|
return wantarray ? ($d, '', time) : $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +178,7 @@ __END__
|
|||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
MojoX::Renderer::TT - Template Toolkit renderer for Mojo
|
Mojolicious::Plugin::TtRenderer::Engine - Template Toolkit renderer for Mojo
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
@@ -190,9 +191,9 @@ Add the handler:
|
|||||||
$self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}});
|
$self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}});
|
||||||
|
|
||||||
# Or manually
|
# Or manually
|
||||||
use MojoX::Renderer::TT;
|
use Mojolicious::Plugin::TtRenderer::Engine;
|
||||||
|
|
||||||
my $tt = MojoX::Renderer::TT->build(
|
my $tt = Mojolicious::Plugin::TtRenderer::Engine->build(
|
||||||
mojo => $self,
|
mojo => $self,
|
||||||
template_options => {
|
template_options => {
|
||||||
PROCESS => 'tpl/wrapper',
|
PROCESS => 'tpl/wrapper',
|
||||||
@@ -240,7 +241,7 @@ Supported parameters are
|
|||||||
|
|
||||||
=item mojo
|
=item mojo
|
||||||
C<build> currently uses a C<mojo> parameter pointing to the base class (Mojo).
|
C<build> currently uses a C<mojo> parameter pointing to the base class (Mojo).
|
||||||
object. When used the INCLUDE_PATH will be set to
|
object. When used the INCLUDE_PATH will be set to
|
||||||
|
|
||||||
=item template_options
|
=item template_options
|
||||||
|
|
||||||
@@ -271,7 +272,7 @@ make changes.
|
|||||||
|
|
||||||
You can find documentation for this module with the perldoc command.
|
You can find documentation for this module with the perldoc command.
|
||||||
|
|
||||||
perldoc MojoX::Renderer::TT
|
perldoc Mojolicious::Plugin::TtRenderer::Engine
|
||||||
|
|
||||||
You can also look for information at:
|
You can also look for information at:
|
||||||
|
|
||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
use Test::More tests => 1;
|
use Test::More tests => 1;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use_ok( 'MojoX::Renderer::TT' );
|
use_ok( 'Mojolicious::Plugin::TtRenderer::Engine' );
|
||||||
}
|
}
|
||||||
|
|
||||||
diag( "Testing MojoX::Renderer::TT $MojoX::Renderer::TT::VERSION, Perl $], $^X" );
|
diag( "Testing Mojolicious::Plugin::TtRenderer::Engine $Mojolicious::Plugin::TtRenderer::Engine::VERSION, Perl $], $^X" );
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ use Test::Mojo;
|
|||||||
# Silence
|
# Silence
|
||||||
app->log->level('fatal');
|
app->log->level('fatal');
|
||||||
|
|
||||||
use_ok('MojoX::Renderer::TT');
|
use_ok('Mojolicious::Plugin::TtRenderer::Engine');
|
||||||
|
|
||||||
plugin 'tt_renderer' => {template_options => {PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1}};
|
plugin 'tt_renderer' => {template_options => {PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1}};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user