#!/usr/bin/perl use strict; use warings; use CGI; use HTML::Template; my $q = CGI->new; # New template object my $template = HTML::Template->new(filename => 'main.tmpl'); my $name = "Prototype"; my $return_val_from_tables = tables(); ### Build form one(1) my $back_form_one = build_form_one(); # New template object for form one my $form_one_tmpl = HTML::Template->new(filename => 'form_one.tmpl'); $form_one_tmpl->param( FORM_ONE => $back_form_one, NAME => 'FORM ONE TEST', ); # Prepare to input into the main template my $form_one_tmpl_loaded = $form_one_tmpl->output(); # The results will be into a VAR in main template main.tmpl $template->param( ONE_DATA=> $form_one_tmpl_loaded, ); # End loading form one data into main template ### Build form two(2) my $back_form_two = build_form_two(); # New template object for form two my $form_two_tmpl = HTML::Template->new(filename => 'form_two.tmpl'); $form_two_tmpl->param( TWO_FORM => $back_form_two, NAME => 'FORM 2 TEST', ); # Prepare to input into the main template my $form_two_tmpl_loaded = $form_two_tmpl->output(); # The results will be into a VAR in main template main.tmpl $template->param( TWO_DATA=> $form_two_tmpl_loaded, ); # End loading form two data into main template ### Build form three(3) my $back_form_three = build_form_three(); # New template object for form three my $form_three_tmpl = HTML::Template->new(filename => 'form_three.tmpl'); $form_three_tmpl->param( THREE_FORM => $back_form_three, NAME => 'FORM 3 TEST', ); # Prepare to input into the main template my $form_three_tmpl_loaded = $form_three_tmpl->output(); # The results will be into a VAR in main template main.tmpl $template->param( THREE_DATA=> $form_three_tmpl_loaded, ); # End loading form three data into main template # Fill in some more parameters into the main tmpl file $template->param( NAME => $name, STUFF => 'TEST', LOAD => $return_val_from_tables, ); # Template output print $q->header, $template->output; sub one { my @data = ( ... ) ; # Load new template to add to main template later my $table_tmpl = HTML::Template->new(filename => 'templates/table.tmpl', die_on_bad_params => 0,); #Load these values into the template $table_tmpl->param( DATA => \@data, ); # Load this template into main template my $table_load = $table_tmpl->output(); return $table_load; }