Created
September 21, 2011 06:53
-
-
Save anonymous/1231426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
helper stuff_some_foo => sub { shift->stash(foo => 'bar'); }; | |
helper stuff_some_baz => sub { shift->stash(baz => 'xyz'); }; | |
app->routes->bridge('/')->to( cb => sub { shift->stuff_some_foo; } ); | |
get '/' => sub { | |
my $self = shift; | |
$self->render( text => 'foo: '.$self->stash('foo') ); | |
}; | |
under '/u' => sub { return shift->stuff_some_baz; }; | |
get sub { | |
my $self = shift; | |
return $self->render( text => sprintf( | |
"baz: %s, foo: %s\n", | |
$self->stash('baz'), | |
$self->stash('foo'), | |
)); | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
% layout 'default'; | |
% title 'Welcome'; | |
Welcome to Mojolicious! | |
@@ layouts/default.html.ep | |
<!doctype html><html> | |
<head><title><%= title %></title></head> | |
<body><%= content %></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment