OK. :)

However, I still thought that there was a problem, namely that of figuring 
out whether + or - suffixes would be useful to change the behavior of how 
templates are found.

So in that case, why build this into the default? Why not provide a 
subclass that will do this already?

Or where you asking more from the point of view of whether you should 
include this in the core API versus providing the functionality in an 
optional subclass.

At 04:28 PM 10/31/2001, Andy Wardley wrote:
>On Wed, Oct 31, 2001 at 08:03:36AM +0800, Gunther Birznieks wrote:
> > Yes, this is another benefit of using a strategy pattern, it goes beyond
> > simple directory traversal. Theoretically a given strategy driver could be
> > written to search for templates inside databases according to a set of
> > configure-time rules.
>
>What, like subclassing Template::Provider to fetch templates from a
>database?   :-)
>
> > Another useful pattern for these strategy drivers is chaining. So 
> basically
> > if it's not found in one strategy driver it might try a second one...eg
> > attempt to find the schema in a DB but if it's not there, downgrade to 
> file
> > system.
>
>What, like being able to define multiple template providers which are
>chained together in precisely that way?  :-)
>
> > Anyway, the idea here in terms of having made the suggestion is that using
> > this pattern would allow pluggable template search and loads which 
> seems to
> > me what people really want.
>
>That's a very good idea!  :-)
>
> > Of course, the majority of people need a "simple" search pattern that
> > exists now -- it's OK that this is the "default strategy" because you do
> > not want to penalize the majority of user's whose needs may be simple. But
> > the goal would be to make power user's capable of doing a lot of different
> > search patterns.
>
>Indeed.  In case you hadn't got the message from the numerous smileys,
>that's exactly how TT currently works.  The Template::Provider module
>implements the strategy fo finding and fetching templates.  Chris Nandor
>has indeed subclassed it to serve templates from a database for Slashdot.
>
>So you can write your own Template::Provider module to implement any kind
>of search algorithm.  The LOAD_TEMPLATES option allows you to specify one
>or more template providers to be search in turn, chain-of-command style.
>
>     my $provider = My::Provider->new(...);
>     my $template = Template->new( LOAD_TEMPLATES => $provider );
>
>You can also give names to different providers to map particular template
>request onto certain strategies:
>
>     my $template = Template->new(
>         LOAD_TEMPLATES => [ $regular, $search, $database, $http ],
>         PREFIX_MAP => {
>             find   => 1,
>             dbase  => 2,
>             http   => 4,
>         }
>     );
>
>Then you can do:
>
>     [% INCLUDE header %]
>     [% INCLUDE find:header %]
>     [% INCLUDE dbase:header %]
>     [% INCLUDE http://andywardley.com/templates/header %]
>
>The PREFIX_MAP currently isn't documented because I'd like to clean up
>some of the configuration details before I encourage too many people to
>use it.  But in principal, the functionality is there.
>
>
>A

__________________________________________________
Gunther Birznieks ([EMAIL PROTECTED])
eXtropia - The Open Web Technology Company
http://www.eXtropia.com/



Reply via email to