Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cae190a7a | ||
|
|
165c3b39f2 | ||
|
|
460b36497a | ||
|
|
91a817b322 | ||
|
|
e779579347 | ||
|
|
e3db05fcb6 | ||
|
|
3c8ec94a70 | ||
|
|
a3b6ccdb2b | ||
|
|
bbabbf9ac1 | ||
|
|
0a42dd4f90 |
@@ -1,5 +1,15 @@
|
|||||||
Revision history for MojoX-Renderer-TT
|
Revision history for MojoX-Renderer-TT
|
||||||
|
|
||||||
|
0.21 July 29, 2009
|
||||||
|
- Update stash key from 'template_path' to 'template' to
|
||||||
|
match mojo change (Sebastian Knapp)
|
||||||
|
|
||||||
|
0.20 December 9, 2008
|
||||||
|
- Updates to work with Mojo 0.9
|
||||||
|
- Add default INCLUDE_PATH
|
||||||
|
- Made default compile dir not Unix specific (Viacheslav
|
||||||
|
Tikhanovskii)
|
||||||
|
|
||||||
0.10 November 12, 2008
|
0.10 November 12, 2008
|
||||||
- Update to work with named parameters in new version of Mojo
|
- Update to work with named parameters in new version of Mojo
|
||||||
- Instead of "tx" pass the context in the "c" variable
|
- Instead of "tx" pass the context in the "c" variable
|
||||||
|
|||||||
@@ -7,4 +7,7 @@ lib/MojoX/Renderer/TT.pm
|
|||||||
t/00-load.t
|
t/00-load.t
|
||||||
t/pod-coverage.t
|
t/pod-coverage.t
|
||||||
t/pod.t
|
t/pod.t
|
||||||
|
t/render.t
|
||||||
|
t/render/template-error.tt2
|
||||||
|
t/render/template.tt2
|
||||||
.perltidyrc
|
.perltidyrc
|
||||||
|
|||||||
@@ -3,3 +3,5 @@
|
|||||||
\.shipit$
|
\.shipit$
|
||||||
.*\.bak$
|
.*\.bak$
|
||||||
^\.gitignore$
|
^\.gitignore$
|
||||||
|
\.DS_Store
|
||||||
|
Makefile
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ WriteMakefile(
|
|||||||
PL_FILES => {},
|
PL_FILES => {},
|
||||||
PREREQ_PM => {
|
PREREQ_PM => {
|
||||||
'Test::More' => 0,
|
'Test::More' => 0,
|
||||||
'Mojo' => 0.8011,
|
'Mojo' => 0.991237,
|
||||||
'Template' => 2.18,
|
'Template' => 2.18,
|
||||||
},
|
},
|
||||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ use base 'Mojo::Base';
|
|||||||
|
|
||||||
use Template ();
|
use Template ();
|
||||||
use Carp ();
|
use Carp ();
|
||||||
|
use File::Spec ();
|
||||||
|
|
||||||
our $VERSION = '0.10';
|
our $VERSION = '0.21';
|
||||||
|
|
||||||
__PACKAGE__->attr('tt', chained => 1);
|
__PACKAGE__->attr('tt', chained => 1);
|
||||||
|
|
||||||
@@ -31,8 +32,9 @@ sub _init {
|
|||||||
# take and process options :-)
|
# take and process options :-)
|
||||||
|
|
||||||
my %config = (
|
my %config = (
|
||||||
|
( $mojo ? (INCLUDE_PATH => $mojo->home->rel_dir('templates') ) : () ),
|
||||||
COMPILE_EXT => '.ttc',
|
COMPILE_EXT => '.ttc',
|
||||||
COMPILE_DIR => ($dir || "/tmp"),
|
COMPILE_DIR => ($dir || File::Spec->tmpdir),
|
||||||
UNICODE => 1,
|
UNICODE => 1,
|
||||||
ENCODING => 'utf-8',
|
ENCODING => 'utf-8',
|
||||||
CACHE_SIZE => 128,
|
CACHE_SIZE => 128,
|
||||||
@@ -48,17 +50,14 @@ sub _init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub _render {
|
sub _render {
|
||||||
my ($self, $mojo, $args) = @_;
|
my ($self, $renderer, $c, $output) = @_;
|
||||||
|
|
||||||
$args->{args} ||= {};
|
my $template_path = $c->stash->{template};
|
||||||
|
|
||||||
#use Data::Dump qw(dump);
|
|
||||||
#warn dump(\$args);
|
|
||||||
|
|
||||||
unless (
|
unless (
|
||||||
$self->tt->process(
|
$self->tt->process(
|
||||||
$args->{path}, {%{$args->{args}}, c => $args->{c}},
|
$template_path, {%{$c->stash}, c => $c},
|
||||||
$args->{output}, {binmode => ":utf8"}
|
$output, {binmode => ":utf8"}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -90,7 +89,7 @@ Add the handler:
|
|||||||
sub startup {
|
sub startup {
|
||||||
...
|
...
|
||||||
|
|
||||||
my $tt = MojoX::Renderer::TT->new(
|
my $tt = MojoX::Renderer::TT->build(
|
||||||
mojo => $self,
|
mojo => $self,
|
||||||
template_options =>
|
template_options =>
|
||||||
{ PROCESS => 'tpl/wrapper',
|
{ PROCESS => 'tpl/wrapper',
|
||||||
|
|||||||
+8
-2
@@ -6,18 +6,24 @@ use warnings;
|
|||||||
use Test::More tests => 5;
|
use Test::More tests => 5;
|
||||||
|
|
||||||
use Mojo::Transaction;
|
use Mojo::Transaction;
|
||||||
|
use MojoX::Context;
|
||||||
|
|
||||||
use_ok('MojoX::Renderer::TT');
|
use_ok('MojoX::Renderer::TT');
|
||||||
|
|
||||||
|
my $c = MojoX::Context->new;
|
||||||
|
|
||||||
my $mt = MojoX::Renderer::TT->build;
|
my $mt = MojoX::Renderer::TT->build;
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
my $rv;
|
my $rv;
|
||||||
|
|
||||||
$rv = $mt->(undef, { path => 't/render/template.tt2', output => \$output });
|
$c->stash->{template} = 't/render/template.tt2';
|
||||||
|
|
||||||
|
$rv = $mt->(undef, $c, \$output);
|
||||||
is($rv, 1);
|
is($rv, 1);
|
||||||
is($output, "4\n");
|
is($output, "4\n");
|
||||||
|
|
||||||
$rv = $mt->(undef, { path => 't/render/template-error.tt2', output => \$output });
|
$c->stash->{template} = 't/render/error.tt2';
|
||||||
|
$rv = $mt->(undef, $c, \$output);
|
||||||
is($rv, 0);
|
is($rv, 0);
|
||||||
ok($output);
|
ok($output);
|
||||||
|
|||||||
Reference in New Issue
Block a user