Made it more modern

This commit is contained in:
vti committed 2010-06-15 12:27:12 +02:00
1 parent a2ce996b97
commit 96d2be17b4
8 files changed
+223 -72

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Test::More tests => 17;
use Mojolicious::Lite;
use Mojo::ByteStream 'b';
use Test::Mojo;
# Silence
app->log->level('fatal');
use_ok('MojoX::Renderer::TT');
plugin 'tt_renderer';
get '/exception' => 'error';
get '/with_include' => 'include';
get '/with_wrapper' => 'wrapper';
get '/unicode' => 'unicode';
get '/on-disk' => 'foo';
get '/foo/:message' => 'index';
my $t = Test::Mojo->new;
# Exception
$t->get_ok('/exception')->status_is(500)->content_like(qr/error/i);
# Normal rendering
$t->get_ok('/foo/hello')->content_is("hello\n\n");
# With include
$t->get_ok('/with_include')->content_is("Hello\n\nInclude!\n\n");
# With wrapper
$t->get_ok('/with_wrapper')->content_is("wrapped\n\n\n");
# Unicode
$t->get_ok('/unicode')->content_is(b("привет")->encode('UTF-8')->to_string . "\n");
# On Disk
$t->get_ok('/on-disk')->content_is("4\n");
# Not found
$t->get_ok('/not_found')->status_is(404)->content_like(qr/not found/i);
__DATA__
@@ index.html.tt
[% message %]
@@ error.html.tt
[% 1 + % %]
@@ include.inc
Hello
@@ include.html.tt
[% INCLUDE 'include.inc' -%]
Include!
@@ wrapper.html.tt
[%- WRAPPER 'layout.html.tt' -%]
rappe
[%- END -%]
@@ layout.html.tt
w[% content %]d
@@ unicode.html.tt
привет
-39
View File
@@ -1,39 +0,0 @@
#!perl
use strict;
use warnings;
use Test::More tests => 6;
use Mojolicious;
use Mojolicious::Controller;
use MojoX::Renderer;
use_ok('MojoX::Renderer::TT');
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_path} = 't/render/template.tt2';
$rv = $mt->(undef, $c, \$output);
is($rv, 1);
is($output, "4\n");
$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
View File
@@ -1 +0,0 @@
[% = 2 %]
-1
View File
@@ -1 +0,0 @@
[% 2 + 2 %]
File renamed without changes.