Ryan Blomberg wrote:
1) Don't ever return arrays or hashes from subroutines or else subscribe to the "Life is a hack" motto

There's no ambiguity as long as you always return a reference to a list rather than a list. So do this:

    return [$x, $y, $z];

Rather than this:

    return ($x, $y, $z);

2) Hate perl..
3) Love perl...

Perl... you gotta hate/love it.  :-)

4) Find an excuse to prevent template builders from calling subroutines directly ( MVC paradigm ) and act religious about it.

There's nothing wrong or anti-MVC about calling subroutines/methods directly from a template per se. What matters (if you want to be strict) is that you don't call methods or subroutines that have external side-effects.

These are "good":

   [% user.name %]                      # Calling a method is OK

   [% FOREACH order IN user.orders %]   # This one does a DB call - fine!

These are "bad":

   [% user.cancel_order %]              # The wrong kind of methods

   [% user.send_more_money %]           # Bad, bad, bad

   [% user.run_with_scissors %]         # Asking for trouble

If you want a simple rule then it's this:

   "Read methods good.  Write methods bad"


Cheers
A


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to