in reply to Use of HTML::Template

The second example in the HTML::Template documentation given for the new method is:

my $t = HTML::Template->new( scalarref => $ref_to_template_text, option => 'value' );

which seems to cover your use case.


Perl's payment curve coincides with its learning curve.

Replies are listed 'Best First'.
Re^2: Use of HTML::Template
by Anonymous Monk on Feb 08, 2009 at 08:45 UTC
    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

      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