/
SingleFileTestApp.pm
56 lines (41 loc) · 1.12 KB
/
SingleFileTestApp.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright (C) 2008-2009, Sebastian Riedel.
package SingleFileTestApp;
use strict;
use warnings;
use base 'Mojolicious';
# Alright, grab a shovel. I'm only one skull short of a Mouseketeer reunion.
sub startup {
my $self = shift;
# Only log errors to STDERR
$self->log->path(undef);
$self->log->level('fatal');
# Default handler
$self->renderer->default_handler('epl');
# /*/* - the default route
$self->routes->route('/:controller/:action')->to(action => 'index');
}
package SingleFileTestApp::Foo;
use strict;
use warnings;
use base 'Mojolicious::Controller';
sub bar {
my $self = shift;
$self->res->headers->header('X-Bender', 'Bite my shiny metal ass!');
$self->render_text($self->url_for);
}
sub data_template {
shift->render('index', template_class => 'SingleFileTestApp::Foo');
}
sub data_template2 {
shift->stash(
template => 'too',
template_class => 'SingleFileTestApp::Foo'
);
}
sub index { shift->stash(template => 'withlayout', msg => 'works great!') }
1;
__DATA__
@@ index.html.epl
<%= 20 + 3 %> works!
@@ too.html.epl
This one works too!