At 11:48 AM on 15 Dec 2009, QaR QaR wrote: > Thank you very much for your answer. > However, I really do need to do this from within a RAWPERL > block...the way I'm doing is ok or is there any other way? > Please help.
No, you don't need to use RAWPERL. In my 5 years with Templates, I never have. There are always many other ways to do what you need. For instance: 1. you can write a plugin to do your perl stuff, or 2. you can massage your data in the original perl before you call Template, or 3. you can try to be more creative with your template code. RAWPERL is a Bad Idea, and you need to Find Another Way. If you do end up using RAWPERL, don't send an email to the mailing list asking if you're doing it right... because the only answer is NO. If you are experiencing a problem, I think you need to rephrase the question and make it clear what's going wrong. > On Tue, Dec 15, 2009 at 10:54 AM, Ronald J Kimball < > [email protected] <rkimball%[email protected]>> wrote: > > > QaR QaR wrote: > > > > I'm sending the request object in the handler, like this: > >> my $r = shift; > >> my $request = Apache2::Request->new($r); > >> my %vars = (request => $request,...); > >> $TT->process($file_path, \%vars, $r) || return > >> error($r,$TT->error( )) > >> > >> And then, in the template, I do the following to access the request > >> object: > >> [%RAWPERL%]my $request = $stash->get('request');[%END%] > >> > >> I know it's working because I can get the parameters from the > >> request object by doing this: > >> [%RAWPERL%] > >> my $request = $stash->get('request'); > >> my $param1 = $request->param('param1'); > >> $output .= $param1; > >> [%END%] > >> > > > > You don't need to use RAWPERL for this. You can just access the > > request TT variable with normal TT syntax. This will render the > > value of param1 in the output: > > > > [% request.param('param1') %] > > > > Ronald > > -- C. Chad Wallace, B.Sc. The Lodging Company http://www.lodgingcompany.com/ OpenPGP Public Key ID: 0x262208A0
signature.asc
Description: PGP signature
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
