Bill, I responded to a similar post of yours back in November:

http://template-toolkit.org/pipermail/templates/2005-November/008042.htm
l

Does this address the same issue, or am I misunderstanding your current
issue?

Jason 

Bill Moseley wrote:
> On Fri, Feb 17, 2006 at 08:23:00AM +0000, Andy Wardley wrote:
> > I suspect your options method is returning a list of 
> hashes, rather than
> > a reference to a list of hashes.
> > 
> >     return [EMAIL PROTECTED];     # good
> >     return  @hashes;     # bad
> > 
> > In the first case you should always get what you expect.  
> In the second
> > case, TT will notice if you return multiple values (e.g. 
> @hashes > 1)
> > and fold it into a list reference.  But if there's only one 
> item then
> > TT will assume you meant to return that and won't fold it 
> into a list.
> 
> Ah!  It's not TT flattening, it's TT folding.
> 
> I forgot that I'm using Rose::Object, and
> Rose::Object::MakeMethods::Generic says for its array methods it does:
> 
>     Interfaces
>        "get_set"
>            If called with no arguments, returns the array contents in
>            list context or a reference to the actual array 
> stored by the
>            object in scalar context.
> 
> So I need to to force reading the object in scalar context.
> 
> Oh, this is ugly:
> 
>         x = field.options.size > 2 ? field.options : [ 
> field.options ];
> 
>         FOR i = x;
>             "<option value='$i.value'>";
>             i.label | html;
>             "</option>\n";
>         END;
> 
> I suspect there's something better.

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

Reply via email to