Hi,

I not sure if this is possible but this is what I'm trying to do

In my HTML file I have the following:

[% FOREACH br = prod.getCategory(category => "XYZ") %]
        # do something with br
[% END %]

Then in my code I have this:

my $prod = new Prod();
$vars->{product} = {
        getCategory => $prod->getCategory()
};
package Prod;
sub new {
        # usual stuff   
}

sub getCategory {
        my $self = shift;
        my $params = ref $_[-1] eq 'HASH' ? pop : { };
        my $category = $params->{ category };
        warn $category;
}

This doesn't work. I know I'm probably doing something really silly but
can't for the life of me work it out.

If I change my code to:
$vars->{product} = {
        getCategory => \&getCategory
};

sub getCategory {
        my $params = ref $_[-1] eq 'HASH' ? pop : { };
        my $category = $params->{ category };
        warn $category;
}

I get what I expect. The problem is that I really need to be able to
call this other module (Prod).

Any clues would be great.

TIA

Andy


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to