[Templates] listifying "scalars"

Jess Robinson castaway@desert-island.demon.co.uk
Mon, 25 Sep 2006 12:42:03 +0100 (BST)


Hi folks,

The 2.15 has an enhancement whereby using .list on a "scalar" should turn 
it into a list. I quote the word "scalar", because it appears to really 
mean "simple scalar", i.e. not references, or blessed refs. The docs 
should probably reflect this.

Anyway, that leaves me with a problem. My sub returns a list of blessed 
objects, except that when there's only one, TT conveniently de-listifies 
the result, however since I'd like to access it as a list anyway, I used 
.list on it, which conveniently turns it into a list of hashrefs with 
values and keys.. i.e. treats it as a hashref. Code that worked in 2.14, 
in the SQL::Translator test suite i.e.:

[% table.pkey_fields.join(", ") %]

Now fails to work in 2.15, when the result of pkey_fields is a single 
object.. Adding .list does not fix this.

Any ideas how to fix this backwards compat problem, or how to make the 
test suite work with lists of blessed scalars?

Jess