Hi dhoss!

Taking a cue from jeffa.

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.

#!/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>
output:
---------- 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.