On Fri, 26 Feb 2016 18:31:47 +0000 "Norris, Joseph" <jnor...@pacificmetrics.com> wrote:
> Hello all, > > Did quite a bit of work with TT some years ago - just coming into a > project where it will be ideal. > > Here is my issue: > > I am converting a bunch of html embedded scripts into TT based > scripts and I have a situation where ( for lack of better words ) I > must "append" parts of forms to other parts - so I have a the > following mockup > > > first_part_of_form > on condtion - keep first_part_of_form and append > second_part_of_form > > > I have tried setting if conditions in my perl script and do the > process to a variable but when I do the following: > > $form->{set_first_part} = true > and then in the form I have [% IF set_first_part == 'true' %] > > first_part_of_form > [% END %] > > And then set it to false - as expected I do not get the > first_part_of_form - I need to keep this intact and then append > second_part_of_form > > Maybe I am over-thinking this but I would like to get to as close as > I can to a single html file to handle what I am doing. It would be much clearer if you posted exactly what you have in your files--your exact perl script and your exact template. I'm probably missing something, but what it seems you're asking for is very straight-forward: $ cat > template.tt header stuff [% IF set_first_part %] first part of form [% END %] [% IF set_second_part %] second part of form [% END %] footer stuff $ cat > test.pl use Template; my $tt = Template->new; my $tt_vars = { 'set_first_part' => 1, # 1 or 0 'set_second_part' => 1, # 1 or 0 }; unless ( $tt->process( 'template.tt', $tt_vars ) ) { die "Template error: " . $tt->error; } $ perl test.pl header stuff first part of form second part of form footer stuff $ -- C. Chad Wallace, B.Sc. The Lodging Company http://www.lodgingcompany.com/ OpenPGP Public Key ID: 0x262208A0 _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates