> Thanks, that works, but I'm still a bit confused about the 
> passing of hashrefs to object methods from within TT. This 
> does not work:


> [%
> criteria = {
>   'image_type' => 1
> };
> images = product.images( criteria );
> %]

If 'images' method really expects hashref - this should work ok.
Try to insert parameters dumping into this method.


> Is the problem here simply that TT doesn't allow you to pass 
> a hashref to an object method?

TT _does_ allow to pass hashref, and even more - it _will_ pass a
hashref when you write code like this (note, that there is no
curly brackets!):

[% images = product.images( 'image_type' => 1 ); %]

This is a bit confusing, because there is still modules, which
accept parameters as hash, not hasref. Example:

sub method {
        my %params = @_;
        # do something with $params{param_key}
}

In this case you have to write:

[% some.method( 'param_key', 'param_value' ); # passes an array of
params %]

Instead of convenient:

[% some.method( param_key => 'param_value' ); # this passes a
hasref and thus DOES NOT WORK %]


-- 
Sergey Martynoff


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

Reply via email to