At 04:36 PM 1/7/02 -0500, you wrote:
>Hello all,
>
>I've just begun to use CGI::FastTemplate and I get the feeling I am 
>misunderstanding
>something.  I have read the perldoc repeatedly, but I guess it's just not
>sinking in.  If anyone can lend some insight, it would be much appreciated.
>
>I have done the following:
>
>1) Created an HTML template file which contains HTML code (of course) and
>the names of variables that are populated in my script.  For example, if
>the following line is in my template file:
>
><td>Hello $name</td>
>
>Then somewhere in my perl script, you will find:
>
>my $name = "Ian";
>
>2) Included the following in the perl script:
>
>CGI::FastTemplate->set_root("/where/my/templates/are");
>$tpl->define( main   => "filename.tpl");
>$tpl->parse( PAGE  => "main");
>$tpl->print(PAGE);
>
>I get the feeling I am misinterpreting how CGI::FastTemplate works, but
>what I see is that the script does indeed print my template file, but does
>not replace any of my variables at all (with strict on, I can see them in
>the output quite clearly).  So I am left to wonder, did I just make a silly
>mistake, or did I misinterpret how it works?  That is, I believe I am most
>confused by the syntax of $tpl->parse().  Does this just tell FastTemplate
>to parse the template file and replace the variables with those in the script,
>or do I have to actually define a separate variable for each one I want
>FastTemplate to replace?  In the code above, I picked "PAGE" as an arbitrary
>name representing my template with all variables replaced.  Should this
>instead be the name of a variable in itself that I want parsed in the 
>template,
>meaning I need to call $tpl->parse() for each and every one of my variables?
>
>I hope I have been clear.  Again, any insight into my confusion is 
>appreciated.
>
>-Ian

>This probably should be addressed to [EMAIL PROTECTED], but since I 
>think I can help, here goes.

You need to use the assign method before the parse.  tpl->assign($hashref)
This method expects a hasref as an argument.  Put all your variables in 
this hash ref and then pass it to assign.  Also, I think the variable names 
must be all caps.

HTH





Peter Cline
Inet Developer
New York Times Digital


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to