in reply to Re: Appending to Template Toolkit
in thread Appending to Template Toolkit

I couldn't find anything that allowed me to append to a line like this:
$onscreen .= $template->process('screen.html', $temp_data) || di +e $template->error( );
I need to bring this piece of html file with the $date in it into $onscreen so the rest of the code finished its processing.

Replies are listed 'Best First'.
Re^3: Appending to Template Toolkit
by Corion (Patriarch) on Mar 07, 2011 at 20:24 UTC

    Then read the section again. Maybe searching for the word "append" helps. I'm not sure how I could tell things clearer than the documentation already does, which is why I'm pointing you to it instead of regurgitating it here.

      No problem in helping you!Here it is, try this way:
      #!/usr/bin/perl -w use strict; use Template; ... my $template = Template->new( ); my $temp_data = {}; # set variales for template ... # here is how I did for HTML::Template #$template->param(my_date => $date); #$onscreen .= $template->output; # process template with tt $temp_data->{'my_date'} = $date; $template->process('screen.html', $temp_data, \$onscreen) || di +e $template->error( ); ... $onscreen .="</table>";
      Let me know if works!
Re^3: Appending to Template Toolkit
by MidLifeXis (Monsignor) on Mar 07, 2011 at 20:04 UTC

    One note - you will probably run into precedence issues with || vs. or. See perlop for more information.

    --MidLifeXis