Am I right in thinking that by "coerce" you mean using the HTML::Template "associate" option to use a parameter in the CGI query object?
If that is the case then perhaps the following may help.
output:#!/bin/perl5 use strict; use warnings; use CGI::Carp qw( fatalsToBrowser ); package main; my $webapp = App->new(); $webapp->run(); package App; use base 'CGI::Application'; use CGI; sub cgiapp_get_query { my $self = shift; # initilise the query object # with some params my $q = CGI->new( { 'test' => 'test page', 'greeting' => 'Hi there!', } ); return $q; } sub setup { my $self = shift; $self->start_mode('test'); $self->run_modes([qw|test|]); } sub test{ my $self = shift; my $html; { local $/; $html = <DATA>; } my $tmpl_obj = $self->load_tmpl( \$html, associate => $self->query, ); return $tmpl_obj->output(); } __DATA__ <html> <head> <title><!-- TMPL_VAR NAME = TEST --></title> </head> <body> <p><!-- TMPL_VAR NAME = GREETING --></p> </body> </html>
---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" c_app.pl Content-Type: text/html; charset=ISO-8859-1 <html> <head> <title>test page</title> </head> <body> <p>Hi there!</p> </body> </html> > Terminated with exit code 0.
update:
dhoss! You changed your snippet while I preparing this post :-(
Hope this may still be of some use. :-)
In reply to Re: CGI::Application/HTML::Template problem
by wfsp
in thread CGI::Application/HTML::Template problem
by stonecolddevin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |