use strict; use warnings; use Mojolicious::Lite; my %pages = ( '/' => { title => 'Begin', blurb => 'This is where you begin.', choices => [ { text => 'Choice 1', link => '/foo' }, { text => 'Choice 2', link => '/bar' }, ], }, 'foo' => { title => 'Foo', blurb => 'This is what happens when you Foo.', choices => [ { text => 'End', link => '/end' }, ], }, 'bar' => { title => 'Foo', blurb => 'This is what happens when you Bar.', choices => [ { text => 'Restart', link => '/' }, { text => 'End', link => '/end' }, ], }, 'end' => { title => 'End', blurb => 'This is the end.', choices => [], }, ); get '/' => { template => 'index', %{ $pages{'/'} } }; get '/:key' => sub { my $c = shift; my $key = $c->param('key'); return $c->reply->not_found unless $pages{$key}; $c->render( template => 'index', %{ $pages{$key} } ); }; app->start; __DATA__ @@ index.html.ep