Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

MASON - more than templates ?

( #180532=categorized question: print w/ replies, xml ) Need Help??
Contributed by the_Don on Jul 09, 2002 at 16:22 UTC
Q&A  > object-oriented programming


Description:

I have read previous posts regarding the use of MASON and they all categorize MASON as primarily a templating tool. Some posts refer to other embedded perl programs (other than MASON) and specifically mention what is possible. There is no specific mention of MASON's perl capabilities.I have read documentation on the MASON site, and what I have read only says that perl my be embedded.

Does MASON inlcude ALL the functionality of the current version of perl, including object-oriented schemas?

If MASON does claim that all functionality is possible, is it true in practice? If you have had any successes or failures regarding MASON, please elaborate.

(It is possible that the current version of a web site will be completely re-designed. The primary objective is to interface with a DB as well as allow users to designate their own interface to the DB. Thus far, MASON is our #1 contender to be the replacement.)

I thank you in advance for any and all constructive comments and appreciate the resources that are readily available here. If I have placed this in an incorrect category, I apologize.

Answer: MASON - more than templates ?
contributed by cephas

Mason has the flexibitly to be much more than a templating system, it can function more as a development medium, somewhat similar to PHP (I think, I know very little about PHP in reality).

Mason works well for those sticky places where form and function can't quite be separated the way we would all like in an ideal world. You can suddenly stash those code/html chunks away in components (which have inheritence), as well as set up some default behaviours for all of your components.

As for supporting Perl functionality, I've built large scale database applications using Mason, that included things such as anonymous subroutines in config files, debug modules that walked the symbol table and replaced subroutines matching a pattern with stubs, and other perlish type things. I'd have to say I haven't encountered a situation yet that we couldn't get through.

All those things being said, if you just want to get your web folks access to some variables, you'd probably be better off sticking to one of the other great templating systems around, because Mason really is a lot more (think hitting flies with a sledge hammer)

cephas

Answer: MASON - more than templates ?
contributed by archangelq

Mason is a very powerful system, it all depends on your needs. If your target is to have a perlish replacement for PHP, then I'd fully suggest it, having had to work in both a great deal.

My preference is strongly on the perl side, so take this with the grain of salt it's worth, but I find mason to be massively more flexable than PHP.

As for a general purpous templating system, both cephas and merlyn have good points. It comes down to that, you can do nearly anything in Mason that you can do in perl, with the display code nicely seperated, but still closely associated. This is good, but you have to be careful of adding in to lengthy of code into any mason component. Nutshell: The more perl there is, the harder it is for an html design person to come in and edit anything. You have to decide for yourself if that's what you want.

Answer: MASON - more than templates ?
contributed by merlyn

I'd strongly suggest looking at Template Toolkit instead, as it is much more general purpose, and has a mini-language which can be taught to non-Perl-programmers much easier. And yet, you can embed Perl directly if you wish.

Answer: MASON - more than templates ?
contributed by blogical

Two great places for more information on Mason:

Embedding Perl in HTML with Mason by Dave Rolsky & Ken Williams (full text online too!)

Mason HQ for all your fully up-to-date mason info and discussion.

From the preface to the mason book:
"Mason is a tool for embedding the Perl programming language into text, in order to create text dynamically, most often in HTML. But Mason does not simply stop at HTML. It can just as easily create XML, WML, POD, configuration files, or the complete works of Shakespeare."

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (5)
    As of 2014-08-23 05:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (172 votes), past polls