Questions are:

This is actually a pretty tiny app, so it’s actually in MyApp::Article, which loads the original from disk (not a DB). In a larger app I usually have a MyApp::View namespace for that stuff to go in.

I’m not quite sure what you’re asking, so I’ll answer it two different ways. :)

If you mean “how do I decide what goes in the template and what goes in a module?”: I prefer my templates be structural and (except for debugging) keep PERL blocks out of it entirely. If the code isn’t real simple, I find it’s more of a pain to write and maintain as part of the template than in a module. For example, when I have to generate a preview I generate it from the Markdown source. If you truncate Markdown source, you might end up separating the first and second parts of a reference link. That leaves Markdown bits in your rendered HTML, so you have to either clean that up or make sure you also grab the second part of any references. (Maybe instead I should render to HTML first and try to truncate that…) Either way that’s much more Perl than I want in a Template file.

If you mean “how do I decide what’s model code and what’s view support code?”: I struggle with this distinction myself, and I’ve done it a few different ways. :D (I've actually thought about writing a question about this, but haven't gotten around to doing it.) One way I think about it is: if I had a command-line utility that needed the raw data for its own reasons, what would it want to call vs. what the web view wants to call?

Mine are fairly small, single-person projects. I’m not part of a team. The stakes are small. I’m sure it's much different on larger team projects.

– Aaron
Preliminary operational tests were inconclusive. (The damn thing blew up.)

In reply to Re^3: Splitting long text for Template by Radiola
in thread Splitting long text for Template by Bod

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.