Re: [Templates] Perl objects in TT
[prev]
[thread]
[next]
[Date index for 2004/07/23]
Mike Whitaker wrote:
> If I create Template::Plugin::WCMS::Object and apply the necessary
> magic so that it inherits its methods from WCMS::Object, does the
> following....
>
> [% USE o = WCMS::Object;
> SET s = o.published_content %]
Yes, that will work, but it sounds like you're returning an object which
is both a WCMS::Object and a Template::Plugin. That's OK, but you don't
have to do it like that. A plugin can return anything it likes, including
other objects totally unrelated to plugins.
So Template::Plugin::WCMS::Object should inerit from Template::Plugin
so that TT can recognise it as a plugin and load it. But the objects
(or data) returned by the new() method can be any kind of objects you
like, and don't have to be subclassed from Template::Plugin. In this case,
you can return WCMS::Object objects.
Or you could create a single WCMS plugin which provides different methods
to return different kinds of objects.
For example:
[% USE WCMS %]
[% o = WCMS.object(...) %]
[% s = WCMS.story(...) %]
[% p = WCMS.pony(...) %]
Anyway, the point is that your plugin only needs to subclass from
Template::Plugin to help TT find and load it (by inheriting the load() and
new() methods). What the new() method actually returns is entirely up to
you and does not have to be a plugin object.
A
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] Perl objects in TT
Andy Wardley 10:28 on 23 Jul 2004
|