[jifty-devel] Template::Declare Import Bug

David E. Wheeler david at kineticode.com
Mon Oct 5 21:37:54 EDT 2009


Hey All,

I think I've run into a bug in Template::Declare's importing behavior.  
Consider:

     package Foo;
     use base 'Template::Declare';
     use Template::Tags;
     template foo => sub { say 'hello' };

     package Bar;
     use base Template::Declare;
     use Template::Tags;
     import Foo under '/foo';

     package Baz;
     use base Template::Declare;
     use Template::Tags;
     import Foo under '/otherfoo';

In this example, I've imported the Foo templates under /foo in the Bar  
package, and under /otherfoo in the Baz package. The problem is this:  
what should `Foo->path_for('foo')` return? Because I've imported its  
templates into two classes, it currently returns the path is was last  
imported into (/otherfoo/foo). But that only makes sense if you're  
using it from package Baz, not if you're using it from package /Bar.  
What if you want to use it from Bar? What if Bar is the root, but Baz  
is not?

Is `path_for` something that's actually used for something? If so,  
maybe the package name should be passed to it?

     Foo->path_for('Bar'); # returns /foo/foo
     Foo->path_for('Baz'); # returns /otherfoo/foo

Thoughts?

Best,

David


More information about the jifty-devel mailing list