Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have a (grand) idea for a website project. The closes thing I can compare it to is Froogle for a specific market, but with alot more content. I plan on taping into the API's of Amazon, Ebay, and maybe Google as well as some specific vendors who offer API's. For those that do not, I will probably resort to LWP for searching their site for what the user is looking for and presenting it in a pretty format.

Well my problem comes down to picking a technology. I know I want to use Perl, specifically mod_perl. The majority of my Perl code has been non web based (100 line scripts or so). I've written some CGI.pm scripts in the past, but it's been awhile.

I've just got done reading this fine article, but I'm more confused now then before I read it. So I'm wondering if you can help me decide on a template system/technology for the following scenario:

1. I will not be doing the HTML and graphics stuff. I have someone else who will, but he does not use/know Perl. He uses HTML and PHP and a big fan of CSS (as well as myself). So I need something a HTML/PHP developer can work with.

2. I want it to be flexible enough to where I can add additional technology down the road (XML stuff for a RSS newsfeed and a cell phone interface).

3. I would like to embed the perl code right into the HTML, as much as possible, and would rather not have to learn a new mini-language, like CGI.pm (my personal opinion).

4. I want to be able to use as many as modules as needed from CPAN (actually, I don't think this has anything to do with a template system and one of the reasons I want to use mod_perl, but I'm throwing it out just in case).

5. I'm an avid user of DreamWeaver and like it (except for it's templating), so something that is similar to this would be nice (even if it's only text based).

6. A good debugger would be nice.

I'm leaning towards Mason, but I wanted to get a second opinion before starting so I can feal confident going into this and not have to worry about changing in a year from now.

I really appreciate any and all help.

-Anonymous Coward
  • Comment on Help With Choosing a Templating System for my Situation

Replies are listed 'Best First'.
Re: Help With Choosing a Templating System for my Situation
by Tanktalus (Canon) on Mar 24, 2005 at 04:15 UTC
    1. I will not be doing the HTML and graphics stuff. I have someone else who will, but he does not use/know Perl. He uses HTML and PHP and a big fan of CSS (as well as myself). So I need something a HTML/PHP developer can work with.

    I think that right there, I would choose HTML::Template.

    3. I would like to embed the perl code right into the HTML, as much as possible, and would rather not have to learn a new mini-language, like CGI.pm (my personal opinion).

    I think this contradicts requirement number 1. Part of the power of splitting perl from HTML is that you can get your friend to do all the display work while you do all the logic work, and you don't collide by working on the same files. Look up "Model, View, Controller" or "MVC".

    That's not to say there aren't valid times for embedding logic within a template (we're doing that at work, but not for CGI). Just that when you already have a division of labour, it's really handy if that division matches the files you're using.

    2. I want it to be flexible enough to where I can add additional technology down the road (XML stuff for a RSS newsfeed and a cell phone interface).

    You can use HTML::Template for creating XML. May not be the best way, but it will be fast. Depending on what else you're using, you'll want a different URL to get the XML/RSS feed than gets the main pages (even if all the difference is that you're getting a special flag). Your XML/RSS generating routine probably just has to use a different input file (rather than "mainpage.html.template", use "mainpage.rss.template"), and you're done. Alternately, you can just generate the entire XML file using tools such as XML::Twig. Although I'm a huge fan of XML::Twig, I probably would stick to HTML::Template for this.

    6. A good debugger would be nice.

    I'm not sure about how to debug templates... but, by separating the template from the code, I find that it's pretty easy to debug my CGI code at the commandline (my favourite debugger is "perl -d").

Re: Help With Choosing a Templating System for my Situation
by duct_tape (Hermit) on Mar 24, 2005 at 04:13 UTC

    I am a big fan of Mason and it should work well for you. You may also want to consider Apache::ASP as it is also a decent choice and I have used it on projects with good success.

    There has been plenty of discussion recently about templating systems, you may want to look through those posts as well. Such as this one. Use Super Search to find others.

Re: Help With Choosing a Templating System for my Situation
by kprasanna_79 (Hermit) on Mar 24, 2005 at 06:53 UTC
    My suggestion for your project are
    1. U can develop this project completely with perl.
    2. U can use apache as web server.
    3. Use mod_perl for better performance
    4. Use mysql which one the best opensource database.
    5. Most important thing for this project is html template handling which can be done efficiently using HTML::Template
    6. Still Template handling can be done with help of these modules
    7. With all of these stuffs go for MVC architecture which looks good
    8. And u also have perl monks to clear ur doubts when ever u struggle at any point
    --prasanna.k
Re: Help With Choosing a Templating System for my Situation
by satchm0h (Beadle) on Mar 24, 2005 at 14:10 UTC
    We use both HTML::Template and Template Toolkit at work. We started down the HTML::Template road and moved to Template Toolkit for the added flexibility and compiled template caching it provides. They have somwhat different design strategies from which they approach the templating problem. Find the one that works best for you and your environment.

    If you are dead set on mixing your perl and HTML, which I will agree with the other monks is a bad idea, you might look at HTML::Embperl

Re: Help With Choosing a Templating System for my Situation
by jhourcle (Prior) on Mar 24, 2005 at 13:04 UTC
Re: Help With Choosing a Templating System for my Situation
by Anonymous Monk on Mar 25, 2005 at 03:02 UTC
    Thank you all. I think I'm going to try HTML::Template and go from there. From all that I've read, it sounds like my best option at the moment.