IMHO the problems you describe are a symptom of wanting to do too much in the output layer (or template system, or "view" in the MVC model). Back in the old days I learned from a book that most programs are written in the "input - calculations - output" way, meaning first obtain all data, then do all the calculations, and only start to print them when you're all done. If you adhere to that, you don't have the problems you describe.

Mason seems to encourage doing very much work at the template level (or at least the tutorial I once read did), which is why I don't use it.

I also dislike it that in many catalyst tutorials some of the database queries are triggered in from the template.

I can't (yet?) really put my finger on it why it seems wrong, but it just plain feels wrong, and is the reason why I still stick to HTML::Template::Compiled, although it's not as nifty as, for example, Template::Toolkit.

Update: I thought more about why it feels wrong, and one thing that came to my mind is error handling. In Catalyst basically the controller does its work, creates a data structure (in the tutorials mostly DBIx::Class objects), and then hands off all the work to the controller.

But if the template accesses methods from these objects, they can trigger a DB query, which in turn could very well throw an error. But at this point it's too late for the controller to catch it in any meaningful way, since it already made all decisions it has to make.

The only remaining options are

All of them don't sound very convincing to me.


In reply to Re: Output should have multiple segments by moritz
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.