package My::WebApp; use base qw/CGI::Application/; sub setup { my $self = shift; $self->start_mode('show_form'); $self->run_modes( show_form => 'show_form', list_results => 'list_results', show_detail => 'show_detail', ); } sub show_form { my $self = shift; my $tmpl = $self->load_tmpl('search_form.tmpl'); # Set up example data for template $tmpl->param('foo_checked' => '1'); return $tmpl->output(); } sub list_results { my $self = shift; my $tmpl = $self->load_tmpl('list.tmpl'); # Set up example data for template $tmpl->param('widget_loop' => [ { widget_name => 'widget_one', widget_id => '1' }, { widget_name => 'widget_two', widget_id => '2' }, { widget_name => 'widget_three', widget_id => '3' }, ]); return $tmpl->output(); } sub show_detail { my $self = shift; my $tmpl = $self->load_tmpl('detail_view.tmpl'); # Set up example data for template $tmpl->param('foo_id' => '1'); $tmpl->param('foo_name' => 'widget_one'); $tmpl->param('foo_checked' => 1); return $tmpl->output(); }