Mason has a lot going for it. First of all, it uses Perl, not some new dinky language. Its architecture is sound, it is mature, and there are excellent documents on using it.

When I first looked at ASP a good many years ago, that was my reaction too: mixing the code and data is bad, we should be separating it. It's awesome for just dropping in a value in the middle of a paragraph of HTML, and is really no different from how we interpolate in string literals.

But I see that Mason has a few features so you are not forced to mix it to badly. If you decide to use "interpolation" in the same way as with Perl strings, and stick with pre-computed values in variables, and put real code elsewhere: The init section is solid Perl and computes all the needed values.

For repeating lines, you can put a Perl loop around the HTML. In a specialized template notation that is all you could do, but here you could use any Perl any time. But don't. Stick to foreach loops on a % line.

You can also call Mason components from normal Perl expressions, and are not forced to shift gears back and forth to do some computing, emit a component, and compute some more. You could even simply print ordinary Perl strings to the emitted output.

—John


In reply to Re^3: Output should have multiple segments by John M. Dlugosz
in thread Output should have multiple segments by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.