in reply to Mixins (problem in CGI::Prototype and Class::Protototyped with subtemplates)

Sounds like a way to add simple plug-ins.

I'm thinking you want to add a method to the base CGI::Prototype code that takes the new module as a parameter, loads it, then returns the object. Then the TT code can call that method and get the new object back.

That doesn't directly solve the override issue, but if the new object is local to the template you provide, maybe it's not as big an issue?

  • Comment on Re: Mixins (problem in CGI::Prototype and Class::Protototyped with subtemplates)

Replies are listed 'Best First'.
Re^2: Mixins (problem in CGI::Prototype and Class::Protototyped with subtemplates)
by merlyn (Sage) on Mar 16, 2005 at 17:04 UTC
    Yeah, that sorta makes sense now that I think about it. In CGI::Prototype::Hidden, I put:
    sub plugin { my $self = shift; my $name = shift; return $self->new('*' => $self->name_to_page($name)); }
    which will return a new page object that first searches the page's lineage, then the plugin's lineage. Then I can call a subpage like:
    [% INCLUDE subpage.tt self=self.plugin("subpage") other=parms go=here +%]
    and in that subpage, self.THIS and self.THAT can refer to either original-lineage methods or the mixin methods. Cool. And yet, the mixin can also have defaults and overrides. This even works for sub-sub pages.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.