#!/usr/bin/perl use strict; use warnings; use CGI; use HTML::Template; my $q = CGI->new; # New template object my $template = HTML::Template->new(filename => 'main.tmpl'); # I could use _INCLUDE if the $template could read it here # this way I could pass all the _VARs I have into the _INCLUDE file, # but it does not work like that. $template->param( TEST_ONE => ( { F_NAME => 'JOHN', L_NAME => 'DOE' }, ,), ); #=cut # load values into the main template my $name = "Prototype"; my $return_val_from_extra = extra_more(); ### Build First one(1) #my $back_item_one = build_item_one(); # New template object for item one my $form_one_tmpl = HTML::Template->new(filename => 'first.tmpl'); $form_one_tmpl->param( CODE => 'Stuff for Item 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( FIRST_THING=> $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 => 'cityinfo.tmpl'); $form_two_tmpl->param( ZIP => '1123456', ID => '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( CITY_INFO=> $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 => 'location_menu.tmpl'); $form_three_tmpl->param( CITY => 'Planet Earth', NAME => 'FORM 3 TEST Name 123', ); # 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( LOCATION=> $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 => 'TEST', MORE => $return_val_from_extra, ); # Template output print $q->header, $template->output; sub extra_more { my @data = ( #... ) ; # Load new template to add to main template later my $table_tmpl = HTML::Template->new(filename => 'more.tmpl', die_on_bad_params => 0,); #Load these values into the template $table_tmpl->param( DATA => "More Data from here", ); # Load this template into main template my $table_load = $table_tmpl->output(); return $table_load; }