On Wed, 2004-01-21 at 01:45, Andrew Gaffney wrote:
> Dan Anderson wrote:
> > On Tue, 2004-01-13 at 16:05, R. Bryant wrote:
> > 
> >>Hi List,
> >>
> >>Is it possible to use CGI.pm in conjunction with a templating system?
> > 
> > 
> > Whenever you send out anything from your CGI object you'll do something
> > like this, correct?
> > 
> > my $cgi = CGI->new;
> > print $cgi->header;
> > 
> > Well you're *printing* anything you send out.  So if you wanted to
> > insert something between something else you would just print it.
> > 
> > However, I'm not quite sure this response is exactly what you're looking
> > for.  I don't know of any templating systems off the top of my head that
> > allow you to read in some template file and spit out some data. 
> > However, I would assume it would not be too hard to implement.
> 
> Back when I was writing CGI in C (my pre-Perl days), I would create an HTML file 
> that 
> contained %s, %d, etc. in place of where values should go. I would then read in the 
> file 
> to a variable. I would do something like:
> 
> printf($file_that_i_read, value1, value2, value3, value4, value5, value6);
> 
> which worked fairly well. The only problem was that I had to create/edit the HTML 
> templated by hand because any HTML editor would try to escape my '%s' and '%d'. Of 
> course, 
> since I write my HTML by hand anyway, that's not really a problem ;)

Perl's substitution regular expressions work great for that.  I often
use HTML templates where in a section for a table I'll put something
like:
##PUT#DATA#HERE##

And regular expression s[##PUT#DATA#HERE##][$foo] where foo is what I'm
putting in works wonderfully.

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to