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

Im writing a web application that will use a simple layout i have already designed, i have decided that using a parser (such as Mason) that parses the html for perl code, is not the best idea because people may run diffrent web servers or not have the perl modules. Because the html will not ever change i have decided i should choose one of two things. 1. Include all the html into each perl file or 2. keep the html in a single .html file and have my perl files read the html from that and use it. If anyone could input their thoughts, r maybe a perl module that is designed for this i would be very happy :D Thanks
im the king of all i survey. my kingdom has lots of dust on it

Replies are listed 'Best First'.
Re: Web app advice
by jdtoronto (Prior) on Aug 30, 2006 at 16:13 UTC
    1.. Don't put HTML in Perl files or vice-versa, it is a maintenance nightmare.

    2.. Contemplate using HTML::Template which is the simplest of the templating modules.

    jdtoronto

      I thoroughly agree with jdtoronto. A Templating system is what you need.
      Take a look at Template Toolkit (CPAN Template) as an alternative to HTML::Template. It provides an additional level of flexibility.

      Whether you should have that level of flexibility in your view layer is a religious discussion better left elsewhere.


      ...stumbling down the path toward enlightenment
Re: Web app advice
by TGI (Parson) on Aug 30, 2006 at 22:52 UTC

    Consider using PAR to package your modules. That should make installation easy, while allowing you to use whichever modules are appropriate.


    TGI says moo

Re: Web app advice
by enhering (Sexton) on Aug 30, 2006 at 16:25 UTC
    I usually keep the html template in a file with strings like %%MENU%% or %%LOGIN%% in it. To display the file the code reads it line by line, searches for the known %%whatever%% sequences and substitutes them for the dynamic content.
      Fair enough, but it sounds like you have built your own templating system, is that so? If you have, I wonder why when there are so many tried and proven posibilities in CPAN.

      jdtoronto

        the OP already expressed concern that the perl modules may not be available, so it may be worth noting how easy it is to implement a simple templating system if simple and built-in are requirements.
Re: Web app advice
by Xidus (Novice) on Aug 30, 2006 at 23:16 UTC
    Thanks for everyones advice, HTML::Template is working out well. Ill Definatly try out this PAR thing :D
    im the king of all i survey. my kingdom has lots of dust on it