Hum, this slipped by.
But, luckily (??) hit me again:
Want to list ids associated with artists and show the ids in order.
The cd objects stringify to its id.
CD ISs: [% artist.cds.nsort.join( ', ' ) %]
This works if the artist has more than one CD. If they only have one
then I get:
CD IDs: id
Note the string "id".
Now, I if I do:
CD ISs: [% artist.cds.list.nsort.join( ', ' ) %]
That also works except for the one with a single CD which I then get:
CD IDs: HASH(0xb6fd444c)
So, what seems to only works is this:
CD ISs: [% as_list(artist.cds.).nsort.join( ', ' ) %]
Where as_list is:
sub { return ref( $_[0] ) eq 'ARRAY' ? shift : [shift] };
On Wed, Dec 05, 2007 at 09:59:19AM -0800, Bill Moseley wrote:
> On Wed, Dec 05, 2007 at 05:10:31PM +0000, Andy Wardley wrote:
> > In this case you can put a .list on the end of cart.items to explicitly
> > upgrade a single item to a list:
> >
> > items = cart.items.list
>
> That's what I thought, too. Am I not doing this correctly?
>
>
> In perl I added:
>
> $c->stash->{test} = [$cart->items];
>
> Then in the template:
>
> items = cart.items;
>
> count = as_list( items ).size;
> count2 = items.list.size;
> count3 = test.size;
>
> " count = $count count2 = $count2 count3 = $count3 \n" | stderr;
>
>
> And then I get:
>
> count = 1 count2 = 11 count3 = 1
>
>
> --
> Bill Moseley
> [EMAIL PROTECTED]
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
--
Bill Moseley
[EMAIL PROTECTED]
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates