use Mojolicious::Lite;
# Route leading to an action that renders a template
get '/bar' => sub {
my $self = shift;
$self->stash(one => 23);
$self->render('baz', two => 24);
};
app->start;
__DATA__
@@ baz.html.ep
The magic numbers are <%= $one %> and <%= $two %>.
####
get '/bar' => sub {
my $self = shift;
if( $cond ) {
$self->stash( one => 23 );
}
else {
$self->stash( two => 42 );
}
$self->render('baz');
}
app_start;
__DATA__
@@ baz.html.ep
<%= $one %> or <%= $two %>.
####
%= stash 'foo'
% stash foo => 'bar';
...
%= stash('name') // 'Somebody'