Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec4e464d90 | ||
|
|
d7726cfa0e | ||
|
|
68438d57cb | ||
|
|
6cae190a7a | ||
|
|
165c3b39f2 |
@@ -1,5 +1,15 @@
|
|||||||
Revision history for MojoX-Renderer-TT
|
Revision history for MojoX-Renderer-TT
|
||||||
|
|
||||||
|
0.30 September 9, 2009
|
||||||
|
- revert the change of stash key, template_path is the prior
|
||||||
|
source for the template file again (Sebastian Knapp)
|
||||||
|
- reflect recent changes in mojo project (v0.991251) (Sebastian Knapp)
|
||||||
|
- one test with Mojolicious added (Sebastian Knapp)
|
||||||
|
|
||||||
|
0.21 July 29, 2009
|
||||||
|
- Update stash key from 'template_path' to 'template' to
|
||||||
|
match mojo change (Sebastian Knapp)
|
||||||
|
|
||||||
0.20 December 9, 2008
|
0.20 December 9, 2008
|
||||||
- Updates to work with Mojo 0.9
|
- Updates to work with Mojo 0.9
|
||||||
- Add default INCLUDE_PATH
|
- Add default INCLUDE_PATH
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ WriteMakefile(
|
|||||||
PL_FILES => {},
|
PL_FILES => {},
|
||||||
PREREQ_PM => {
|
PREREQ_PM => {
|
||||||
'Test::More' => 0,
|
'Test::More' => 0,
|
||||||
'Mojo' => 0.9,
|
'Mojo' => 0.991251,
|
||||||
'Template' => 2.18,
|
'Template' => 2.18,
|
||||||
},
|
},
|
||||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ use Template ();
|
|||||||
use Carp ();
|
use Carp ();
|
||||||
use File::Spec ();
|
use File::Spec ();
|
||||||
|
|
||||||
our $VERSION = '0.20';
|
our $VERSION = '0.30';
|
||||||
|
|
||||||
__PACKAGE__->attr('tt', chained => 1);
|
__PACKAGE__->attr('tt');
|
||||||
|
|
||||||
sub new { Carp::croak "MojoX::Renderer::TT->new() is now ->build()" }
|
sub new { Carp::croak "MojoX::Renderer::TT->new() is now ->build()" }
|
||||||
|
|
||||||
@@ -50,9 +50,12 @@ sub _init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub _render {
|
sub _render {
|
||||||
my ($self, $renderer, $c, $output) = @_;
|
my ($self, $renderer, $c, $output, $options) = @_;
|
||||||
|
|
||||||
my $template_path = $c->stash->{template_path};
|
my $template_path;
|
||||||
|
unless($template_path = $c->stash->{'template_path'}) {
|
||||||
|
$template_path = $renderer->template_path($options);
|
||||||
|
}
|
||||||
|
|
||||||
unless (
|
unless (
|
||||||
$self->tt->process(
|
$self->tt->process(
|
||||||
@@ -103,22 +106,23 @@ Add the handler:
|
|||||||
And then in the handler call render which will call the
|
And then in the handler call render which will call the
|
||||||
MojoX::Renderer::TT renderer.
|
MojoX::Renderer::TT renderer.
|
||||||
|
|
||||||
$c->render(foo => 123, bar => [qw(giz mo)]);
|
$c->render(templatename, format => 'tex', handler => 'tt2');
|
||||||
|
|
||||||
|
Template parameter are taken from $c->stash
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
=head2 build
|
=head2 build
|
||||||
|
|
||||||
This method returns a handler for the Mojo renderer.
|
This method returns a handler for the Mojolicious renderer.
|
||||||
|
|
||||||
Supported parameters are
|
Supported parameters are
|
||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|
||||||
=item mojo
|
=item mojo
|
||||||
C<new> currently requires 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.
|
object. When used the INCLUDE_PATH will be set to
|
||||||
|
|
||||||
=item template_options
|
=item template_options
|
||||||
|
|
||||||
@@ -134,7 +138,6 @@ Ask Bjørn Hansen, C<< <ask at develooper.com> >>
|
|||||||
=head1 TODO
|
=head1 TODO
|
||||||
|
|
||||||
* Better support non-Mojolicious frameworks
|
* Better support non-Mojolicious frameworks
|
||||||
* Don't require the mojo parameter
|
|
||||||
* Move the default template cache directory?
|
* Move the default template cache directory?
|
||||||
* Better way to pass parameters to the templates? (stash)
|
* Better way to pass parameters to the templates? (stash)
|
||||||
* More sophisticated default search path?
|
* More sophisticated default search path?
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!perl -T
|
#!perl
|
||||||
|
|
||||||
use Test::More tests => 1;
|
use Test::More tests => 1;
|
||||||
|
|
||||||
|
|||||||
+15
-5
@@ -3,14 +3,17 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More tests => 5;
|
use Test::More tests => 6;
|
||||||
|
|
||||||
use Mojo::Transaction;
|
use Mojolicious;
|
||||||
use MojoX::Context;
|
use Mojolicious::Controller;
|
||||||
|
use MojoX::Renderer;
|
||||||
|
|
||||||
use_ok('MojoX::Renderer::TT');
|
use_ok('MojoX::Renderer::TT');
|
||||||
|
|
||||||
my $c = MojoX::Context->new;
|
my $c = Mojolicious::Controller->new(app => Mojolicious->new);
|
||||||
|
$c->app->log->path(undef);
|
||||||
|
$c->app->log->level('fatal');
|
||||||
|
|
||||||
my $mt = MojoX::Renderer::TT->build;
|
my $mt = MojoX::Renderer::TT->build;
|
||||||
|
|
||||||
@@ -18,7 +21,6 @@ my $output;
|
|||||||
my $rv;
|
my $rv;
|
||||||
|
|
||||||
$c->stash->{template_path} = 't/render/template.tt2';
|
$c->stash->{template_path} = 't/render/template.tt2';
|
||||||
|
|
||||||
$rv = $mt->(undef, $c, \$output);
|
$rv = $mt->(undef, $c, \$output);
|
||||||
is($rv, 1);
|
is($rv, 1);
|
||||||
is($output, "4\n");
|
is($output, "4\n");
|
||||||
@@ -27,3 +29,11 @@ $c->stash->{template_path} = 't/render/error.tt2';
|
|||||||
$rv = $mt->(undef, $c, \$output);
|
$rv = $mt->(undef, $c, \$output);
|
||||||
is($rv, 0);
|
is($rv, 0);
|
||||||
ok($output);
|
ok($output);
|
||||||
|
|
||||||
|
delete $c->stash->{template_path};
|
||||||
|
|
||||||
|
$c->app->renderer->root('./')->add_handler(tt2 => $mt);
|
||||||
|
|
||||||
|
is($c->render('t/render/template','partial' => 1,handler => 'tt2'),"4\n");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[% 2 + 2 %]
|
||||||
Reference in New Issue
Block a user