[Templates] where to put the db logic

Andy Wardley abw@andywardley.com
Tue, 7 Jan 2003 10:17:15 +0000


allan wrote:
> [...] below are two versions of the same logic...

The student went to the master and asked:

  "Master, should I follow the way of the cat or the way of the dog?"

The master replied:

  "Follow the way of the animal".

The student was confused:

  "But what is the way of the animal?"

The master replied:
  
  "Whatever you want it to be.  That is the power of abstraction".

The student was enlightened.  He went to his keyboard and typed:

  [% FOREACH being = animal %]
     ...
  [% END %]

Now he we was free to implement animal in the way of the cat or the way
of the dog.  Or indeed in the way of the ant, bee or elk if at some later 
date he favoured more legs, wings or horns.   He didn't need to worry about 
hard-coding nitty-gritty implementation details in his templates and could 
change his way at any time.  

He was at one with the Template Toolkit and the Template Toolkit was at 
one with him.  

Hope that helps to balance your karma.  :-)

A

PS This particular animal might like to follow the way of the 
   Template::Iterator.  See Template::Plugin::DBI for some inspiration.