[jifty-devel] Difference Between alias and import_templates in Template::Declare
David E. Wheeler
david at kineticode.com
Tue Oct 13 16:37:12 EDT 2009
On Oct 13, 2009, at 11:36 AM, Shawn M Moore wrote:
> I just want to point out that this is an important use case for us. We
> do use the object-oriented features of Template::Declare and it is
> important that they continue to work.
Thanks Shawn. Based on your testing results, I changed things around.
The behavior of `alias` is now as it was before, and
`import_templates` is different.
> The most prevalent use of TD's OO is in Jifty's CRUD builder.
> Basically,
> the CRUD builder is set up like:
>
> sub record_class { ... }
>
> sub display_columns { $self->record_class->... }
> sub edit_columns { $self->record_class->... }
>
> template 'view_item' => sub { ... }
> template 'edit_item' => sub { ... }
>
> I don't think we instantiate an object. We just make use of the
> indirection of OO to let users subclass the CRUD builder to customize
> it. They can, for example, change which columns are editable by
> overriding the edit_columns method.
Yep. And now `import_templates` works with that, too. Previously, it
always passed the class in which each template was defined, but now it
passes in the class that the template is imported from, even if the
template is inherited by that class.
> We also typically use "alias" to nail particular CRUD classes into the
> template tree, so this is kind of a showstopper. :)
Yep, no more.
> As I understand it, you have since fixed this, but I felt you
> deserved a
> good explanation as to why we pass in the particular class we do.
Yes, I appreciate it.
Before we decided to merge this stuff into trunk there were two things
I wanted to get nailed down:
* Improved documentation for this stuff. I'm now working on this and
should commit it later today.
* Discuss if the `alias` behavior really *is* what we want. I ask
because, in a real mixin system, the invocant passed to a mixed-in
method would be an object of the class into which it's mixed, not the
class from which it's mixed. Based on your comments here, I think that
the answer is yes, but I did want to reality-check it. Sound about
right?
Thanks,
David
More information about the jifty-devel
mailing list