http://qs321.pair.com?node_id=603628


in reply to Re^2: CGI::Ajax + Template::Toolkit Question
in thread CGI::Ajax + Template::Toolkit Question

Rather than passing the configuration variables in $config to process, as chargrill noted, you can specify these when creating the $tt object:
my $config = { INCLUDE_PATH => '/tt', INTERPOLATE => 1, POST_CHOMP => 1, PRE_PROCESS => 'header', EVAL_PERL => 1, }; my $tt = Template->new($config);
and then specify the variables you want processed in your template in process:
sub main_page { my $output = ''; my $template = 'main.tt'; my $vars = { title =>'AJAX Login'}; $tt->process($template, $vars, \$output) || die $tt->error(); return $output; }

Replies are listed 'Best First'.
Re^4: CGI::Ajax + Template::Toolkit Question
by stonecolddevin (Parson) on Mar 09, 2007 at 01:01 UTC

    UPDATE:Would still like to know if this would be a usable solution, however problem has been solved.

    Ahhh whoops, don't know how I missed that.

    I was turning this over in my head, the show_javascript function returns the javascript as text...would it be better to have a template variable in the <HEAD> section of my template and insert it via T::T? Perhaps that would rid me of the error being thrown by CGI::Ajax.

    Thoughts?

    meh.
      Yes, you can do that - see the pjx_nobuild.pl example in the CGI::Ajax sources for how to do that (note that the line $html .= $pjx; in the example calls show_javascript, due to the overloading done in CGI::Ajax).