Skip to content

Instantly share code, notes, and snippets.

/testapp.pl Secret

Created September 30, 2015 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/83be5a75d1a24c622915 to your computer and use it in GitHub Desktop.
Save anonymous/83be5a75d1a24c622915 to your computer and use it in GitHub Desktop.
package Testapp;
use Mojo::Base 'Mojolicious';
sub startup {
my $app = shift;
$app->routes->get('/')->to('example#foo');
}
package Testapp::Example;
use Mojo::Base 'Mojolicious::Controller';
sub foo {
my $self = shift;
$self->stash( col => [qw(abc def ghi)] );
$self->respond_to(
html => sub { $self->render( inline => '<%= shift @$col %>' ) },
json => {
json => {
blah => $self->render_to_string( inline => '<%= shift @$col %>' ),
},
},
);
}
Mojolicious::Commands->start_app('Testapp');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment