Roger, Thanks, that does help. I am just starting with HTML::Template and am not a perl whiz ( at this point ).
I have 4 cgi's, each one with different states controlled by hidden params. I need a way to add html and don't want to add directly in the cgi with print statements. Here is another, possibly stoopid question - I have multiple states within each cgi, different and shared html for each state. Should I create a shared template file ( for shared html), then a unique one ( for html unique to that state ), then call two objects in that state or should I just have one object and merge the shared and unique html in the template file? matt -----Original Message----- From: Roger Burton West [mailto:[EMAIL PROTECTED]] Sent: Friday, October 05, 2001 3:49 PM To: [EMAIL PROTECTED] Subject: Re: [htmltmpl] question On Fri, Oct 05, 2001 at 03:37:00PM -0500, Boex,Matthew W. wrote: >hello, > >i have a basic question. i have created a couple cgi's and want to use >HTML::Template with them. can someone explain or send an example of the >associate option. it seems like i should be using that but don't quite get >it from the doc's. You don't say what you're trying to achieve. The associate option is usually used to let template values be filled in automatically from a CGI query - i.e. you want to display what the user has just entered. (You might do this to re-present a form which hasn't had required fields completed, or to ask for confirmation of the user's entry before acting on it.) If the associate option didn't exist, and the form that called the script had set the variables foo, bar and baz, then you could do: my $query=new CGI; my $template=HTML::Template->new(filename => 'template.tmpl'); $template->param(foo => $query->param('foo')); $template->param(bar => $query->param('bar')); $template->param(baz => $query->param('baz')); The associate option is a short-cut to this - the same effect as above (though for _all_ parameters in the query that the script receives) is given by the code: my $query = new CGI; my $template = HTML::Template->new(filename => 'template.tmpl', associate => $query); That's all there is to it. Hope this is of help, Roger --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
