Compare commits
8 Commits
release/0.
...
release/0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4c554a46a | ||
|
|
f2d62f0a25 | ||
|
|
72855bad28 | ||
|
|
29a6a8c946 | ||
|
|
270ec1e6e5 | ||
|
|
ec4e464d90 | ||
|
|
d7726cfa0e | ||
|
|
68438d57cb |
9
.shipit
9
.shipit
@@ -1,9 +0,0 @@
|
||||
# auto-generated shipit config file.
|
||||
steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist
|
||||
|
||||
git.tagpattern = release/%v
|
||||
|
||||
# svn.tagpattern = MyProj-%v
|
||||
# svn.tagpattern = http://code.example.com/svn/tags/MyProj-%v
|
||||
|
||||
# CheckChangeLog.files = ChangeLog, MyProj.CHANGES
|
||||
9
Changes
9
Changes
@@ -1,5 +1,14 @@
|
||||
Revision history for MojoX-Renderer-TT
|
||||
|
||||
0.31 September 11, 2009
|
||||
- Remove deprecated 'new' method
|
||||
- Update MANIFEST (oops, thanks Sebastian)
|
||||
|
||||
0.30 September 9, 2009
|
||||
- Revert the change of template_path stash key
|
||||
- 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)
|
||||
|
||||
8
MANIFEST
8
MANIFEST
@@ -1,13 +1,15 @@
|
||||
.gitignore
|
||||
.perltidyrc
|
||||
Changes
|
||||
lib/MojoX/Renderer/TT.pm
|
||||
Makefile.PL
|
||||
MANIFEST
|
||||
MANIFEST.SKIP
|
||||
Makefile.PL
|
||||
README
|
||||
lib/MojoX/Renderer/TT.pm
|
||||
t/00-load.t
|
||||
t/pod-coverage.t
|
||||
t/pod.t
|
||||
t/render.t
|
||||
t/render/template-error.tt2
|
||||
t/render/template.html.tt2
|
||||
t/render/template.tt2
|
||||
.perltidyrc
|
||||
|
||||
@@ -1,7 +1,44 @@
|
||||
\.git\/
|
||||
.*~$
|
||||
\.shipit$
|
||||
.*\.bak$
|
||||
^\.gitignore$
|
||||
\.DS_Store
|
||||
Makefile
|
||||
# Avoid version control files.
|
||||
\bRCS\b
|
||||
\bCVS\b
|
||||
\bSCCS\b
|
||||
,v$
|
||||
\B\.svn\b
|
||||
\B\.git\b
|
||||
\b_darcs\b
|
||||
|
||||
# Avoid Makemaker generated and utility files.
|
||||
\bMANIFEST\.bak
|
||||
\bMakefile$
|
||||
\bblib/
|
||||
\bMakeMaker-\d
|
||||
\bpm_to_blib\.ts$
|
||||
\bpm_to_blib$
|
||||
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
|
||||
|
||||
# Avoid Module::Build generated and utility files.
|
||||
\bBuild$
|
||||
\b_build/
|
||||
|
||||
# Avoid temp and backup files.
|
||||
~$
|
||||
\.old$
|
||||
\#$
|
||||
\b\.#
|
||||
\.bak$
|
||||
|
||||
# Avoid Devel::Cover files.
|
||||
\bcover_db\b
|
||||
|
||||
### DEFAULT MANIFEST.SKIP ENDS HERE ####
|
||||
|
||||
\.DS_Store$
|
||||
\.sw.$
|
||||
(\w+-)*(\w+)-\d\.\d+(?:\.tar\.gz)?$
|
||||
|
||||
\.t\.log$
|
||||
|
||||
\.prove$
|
||||
|
||||
# XS shit
|
||||
\.(?:bs|c|o)$
|
||||
|
||||
@@ -13,7 +13,7 @@ WriteMakefile(
|
||||
PL_FILES => {},
|
||||
PREREQ_PM => {
|
||||
'Test::More' => 0,
|
||||
'Mojo' => 0.991237,
|
||||
'Mojo' => 0.991251,
|
||||
'Template' => 2.18,
|
||||
},
|
||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||
|
||||
2
README
2
README
@@ -37,7 +37,7 @@ You can also look for information at:
|
||||
|
||||
COPYRIGHT AND LICENCE
|
||||
|
||||
Copyright (C) 2008 Ask Bjørn Hansen
|
||||
Copyright (C) 2008-2009 Ask Bjørn Hansen
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the same terms as Perl itself.
|
||||
|
||||
@@ -8,11 +8,9 @@ use Template ();
|
||||
use Carp ();
|
||||
use File::Spec ();
|
||||
|
||||
our $VERSION = '0.21';
|
||||
our $VERSION = '0.31';
|
||||
|
||||
__PACKAGE__->attr('tt', chained => 1);
|
||||
|
||||
sub new { Carp::croak "MojoX::Renderer::TT->new() is now ->build()" }
|
||||
__PACKAGE__->attr('tt');
|
||||
|
||||
sub build {
|
||||
my $self = shift->SUPER::new(@_);
|
||||
@@ -50,9 +48,12 @@ sub _init {
|
||||
}
|
||||
|
||||
sub _render {
|
||||
my ($self, $renderer, $c, $output) = @_;
|
||||
my ($self, $renderer, $c, $output, $options) = @_;
|
||||
|
||||
my $template_path = $c->stash->{template};
|
||||
my $template_path;
|
||||
unless($template_path = $c->stash->{'template_path'}) {
|
||||
$template_path = $renderer->template_path($options);
|
||||
}
|
||||
|
||||
unless (
|
||||
$self->tt->process(
|
||||
@@ -103,22 +104,23 @@ Add the handler:
|
||||
And then in the handler call render which will call the
|
||||
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
|
||||
|
||||
=head2 build
|
||||
|
||||
This method returns a handler for the Mojo renderer.
|
||||
This method returns a handler for the Mojolicious renderer.
|
||||
|
||||
Supported parameters are
|
||||
|
||||
=over 4
|
||||
|
||||
=item mojo
|
||||
C<new> currently requires a C<mojo> parameter pointing to the base class (Mojo).
|
||||
object.
|
||||
C<build> currently uses a C<mojo> parameter pointing to the base class (Mojo).
|
||||
object. When used the INCLUDE_PATH will be set to
|
||||
|
||||
=item template_options
|
||||
|
||||
@@ -134,7 +136,6 @@ Ask Bjørn Hansen, C<< <ask at develooper.com> >>
|
||||
=head1 TODO
|
||||
|
||||
* Better support non-Mojolicious frameworks
|
||||
* Don't require the mojo parameter
|
||||
* Move the default template cache directory?
|
||||
* Better way to pass parameters to the templates? (stash)
|
||||
* More sophisticated default search path?
|
||||
@@ -185,7 +186,7 @@ L<http://search.cpan.org/dist/MojoX-Renderer-TT/>
|
||||
|
||||
=head1 COPYRIGHT & LICENSE
|
||||
|
||||
Copyright 2008 Ask Bjørn Hansen, all rights reserved.
|
||||
Copyright 2008-2009 Ask Bjørn Hansen, all rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the same terms as Perl itself.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!perl -T
|
||||
#!perl
|
||||
|
||||
use Test::More tests => 1;
|
||||
|
||||
|
||||
24
t/render.t
24
t/render.t
@@ -3,27 +3,37 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 6;
|
||||
|
||||
use Mojo::Transaction;
|
||||
use MojoX::Context;
|
||||
use Mojolicious;
|
||||
use Mojolicious::Controller;
|
||||
use MojoX::Renderer;
|
||||
|
||||
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 $output;
|
||||
my $rv;
|
||||
|
||||
$c->stash->{template} = 't/render/template.tt2';
|
||||
|
||||
$c->stash->{template_path} = 't/render/template.tt2';
|
||||
$rv = $mt->(undef, $c, \$output);
|
||||
is($rv, 1);
|
||||
is($output, "4\n");
|
||||
|
||||
$c->stash->{template} = 't/render/error.tt2';
|
||||
$c->stash->{template_path} = 't/render/error.tt2';
|
||||
$rv = $mt->(undef, $c, \$output);
|
||||
is($rv, 0);
|
||||
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");
|
||||
|
||||
|
||||
|
||||
1
t/render/template.html.tt2
Normal file
1
t/render/template.html.tt2
Normal file
@@ -0,0 +1 @@
|
||||
[% 2 + 2 %]
|
||||
Reference in New Issue
Block a user