Subject: | List VMethods (sometimes?) not called when argument is a variable |
We have a custom vmethod called "contains". It's implemented like this:
$Template::Stash::LIST_OPS->{ contains } =
sub {
my ($list, $item) = @_;
return grep($_ eq $item, @$list) ? 1 : 0;
};
I have a constant called ITA_FIELDS, which is an arrayref of strings.
In the following testcase, contains() is never called (tested by putting
a "die" in the function):
[% SET this_var = 'a string' %]
[% constants.ITA_FIELDS.contains(this_var) %]
In the following testcase, contains() *is* called:
[% constants.ITA_FIELDS.contains('a string') %]