[rt-users] Re: Perl Question

Jamie Lawrence rtusers-lists-fsck-com at jal.org
Thu Jun 10 22:29:16 EDT 2004


On Thu, 10 Jun 2004, MikeHamilton at clovisusd.k12.ca.us wrote:

> I thought of a better way to word my question, and hopefully this will help
> someone understand the conceptual hurdle that I have in learning about
> this:
> What advantage is there to embedding perl in html (I.e. Mason) vs just
> generating the web page using raw perl (probably using cgi.pm to generate
> the html).

The answer, like almost everything, is "it depends on what you want".

Mason provides a very nice framework for not just generating HTML, but
for reuse of code and design from a site-centric viewpoint. There are a 
number of conveniences (things like autohandlers, dhandlers, inheritance) 
that are extremely useful when designing sites. Note the emphasis - sites,
not pages.

Other approaches are faster, or stick to a stricter MVC framework (which
you can do in Mason, if you want), or different conveniences. 

As far as the difference between embedding Perl in HTML and generating
HTML, in the end, you're doing the same thing. Different people have
different preferences. I personally really appreciate being able to do
simple switches inline in the HTML:

% (if $logged_in) {
Hello, <% $username %>
% } else {
<a href="whatever.html">Please log in</a>
% }

Seems much more natural to me than writing a generator. It is really
purely a matter of preference.

(Actually, I usually do that sort of thing completely inline:
<% $logged_in ? 'Hello, ' . $username : '<a href="whatever.html">Please log in' %>
but some people don't like that.)

That's just one example - we do a lot of (non-RT) Mason work, and find
it the best tool for what we do.

If you're customizing RT, it seems to me to make little sense to bring
in an entirely different toolchain unless you have a really good reason. 
You'll bloat the app, end up writing things that already exist, have 
a lot of friction where the customizations rub up against the rest of 
the app, and likely have a lot of work every time you the base app.


Anyway, that's my $.02. HTH.

-j

-- 
Jamie Lawrence                                        jal at jal.org
Reality is that which, when you stop believing in it, doesn't 
go away.
   - Philip K. Dick




More information about the rt-users mailing list