Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: thoughts on creating modular perl for web application

by moot (Chaplain)
on Mar 14, 2005 at 21:00 UTC ( [id://439448]=note: print w/replies, xml ) Need Help??


in reply to thoughts on creating modular perl for web application

Not sure it's what you're after or not, but have you looked at existing templating systems like Template::Toolkit or HTML::Mason?
  • Comment on Re: thoughts on creating modular perl for web application

Replies are listed 'Best First'.
Re^2: thoughts on creating modular perl for web application
by emilford (Friar) on Mar 14, 2005 at 21:06 UTC
    No, the templating system isn't what I'm after, but rather how to logically organize the chunks of code that the templating system would reference. So I'd have 'monks.pm' that would have a subroutine called getContent(). When [% $monks->getContent(); %] is used in the template system, the correct HTML code would be returned based on monks.pm. Make sense?

      Mason offers more than mere templatting, give it a long look.

      -Any sufficiently advanced technology is
      indistinguishable from doubletalk.

      My Biz

      Mason's various pieces revolve around the notion of "components". A component is a mix of HTML, Perl, and special Mason commands, one component per file. So-called "top-level" components represent entire web-pages, while smaller components typically return HTML snippets for embedding in top-level components.

      This sounds like what you want, but my reading of the docs suggests that components don't quite work like subroutines. Maybe you could give us some more information about exactly how your existing "xyz" template system calls Perl functions. Can you tell us what "xyz" is or is that a trade secret at your company?

        I've looked over Mason and, yes, it does a heck of a lot that would make my life easier. However, I am unable to install modules, so Mason doesn't much help. I brought it up, but the request was shot down.

        It's no trade secret, but let's just assume there is no templating system, but rather a single CGI script that will use the various modules and then dump everything with print statements. As long at the Perl modules return valid HTML in the form of a string, should be good to go.

        I have this dummy CGI script and the Perl modules written. Each module is it's own package with a getContent() subroutine that uses __DATA__ to return the HTML.
        use Footer; my $footer = Footer->new(); print $footer->getContent();
        This approach works, but I'm looking for a more elegant solution, mainly with the indivdual modules as there is a ton of repetition with each module having its own getContent() subroutine. I'm also worried about overlap in any way, if that's possible. Any suggestions?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-23 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found