There are all kinds of things you CAN do in TT, but that doesn't mean you should do them. It sounds like you want macros (which are in the docs), but if these are doing actual Perl processing (as opposed to just encapsulating a display rule) you'd be better off doing it before running the template or at least putting it in a plugin.

If you start shoving lots of subroutines and stuff into your templates, you'll lose the separation that is the whole point of TT. On the other hand, if you really think this is a more appropriate way to write your templates, maybe you should use an in-line Perl templating tool like Text::Template.


In reply to Re: Template Toolkit 2 and subroutines by perrin
in thread Template Toolkit 2 and subroutines by marcink

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.