in reply to Re: Use of HTML::Template
in thread Use of HTML::Template

Thank you...

One more quick question, what is this: (I'll put a comment in front of the code I have a question about...
my $t = HTML::Template->new( scalarref => $ref_to_template_text, # option => 'value' );
I don't understand the option and what it is for.

Thanks

Replies are listed 'Best First'.
Re^3: Use of HTML::Template
by GrandFather (Saint) on Feb 08, 2009 at 08:51 UTC

    A place holder for any of the optional parameters to the new method. Sorta like saying ...->new (foo => 'bar', boo => 'baz', ...). The 'scalerref' option is the interesting one and you can remove the commented line without any nasty surprises.


    Perl's payment curve coincides with its learning curve.
      Thanks again.

      So if I want to use that for merging all the variables of a page, could I do it like this:
      my $template = HTML::Template->new( scalarref => $html_content, %_array_of_fields ); );

      Where
      %_array_of_fields = ( 'option' => "$option", 'option2' => "$option2", 'option3' => "$someOtherOptionVariable", );
      would that work?

      Thank you

        Unfortunately no. According to my reading of the documentation you must use param () to set parameters:

        my $template = HTML::Template->new( scalarref => $html_content); $template->param (%_array_of_fields);

        Perl's payment curve coincides with its learning curve.