Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

2Re: Web app frameworks - I am totally confused!

by jeffa (Bishop)
on Oct 06, 2003 at 04:48 UTC ( #296862=note: print w/replies, xml ) Need Help??


in reply to Re: Web app frameworks - I am totally confused!
in thread Web app frameworks - I am totally confused!

I don't see how your example is more simple than the following:
use strict; use warnings; use CGI qw(header); use HTML::Template; my $tmpl = HTML::Template->new(filehandle => \*DATA); $tmpl->param( title => 'HTML Sample', toc => 'Table of Contents', body => 'Sample text', ); print header, $tmpl->output; __DATA__ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><tmpl_var title></title> </head> <body> <b><tmpl_var toc></b><br/> <i><tmpl_var body></i> </body> </html>
Barring looking under the hood of HTML::Template, of course (hairy stuff - but it works, it's tested, it's ready to go, and it handles loops and includes).

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^3: Web app frameworks - I am totally confused!
by Aristotle (Chancellor) on Oct 06, 2003 at 10:57 UTC
    I can't resist. :)
    use strict; use warnings; use CGI qw(:header); use Template; print header; my $t = Template->new(); $t->process(\*DATA, { title => 'HTML Sample', toc => 'Table of Contents', body => 'Sample text', }) or die $t->error(); __DATA__ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>[% title %]</title> </head> <body> <b>[% toc %]</b><br/> <i>[% body %]</i> </body> </html>
    Of course this example barely shows off anything..

    Makeshifts last the longest.

Re: 2Re: Web app frameworks - I am totally confused!
by Roger (Parson) on Oct 06, 2003 at 08:42 UTC
    I have never used HTML::Template before, seems like a nice and simple way to do templates. Thanks for the tip I will have a look at the module. My solution was a hack I used from time to time without the HTML::Template. The principles applied should be the same.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://296862]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2021-06-20 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (95 votes). Check out past polls.

    Notices?