On Mon, 18 Dec 2006, Scott Lanning wrote:
> What's returned by methods in Bricolage depends on
context.
> In list context, returns a list of objects. In scalar
context,
> returns an array reference.
>
> I don't know anything about Template Toolkit
> (other than it seems like an abomination of nature,
IMHO).
I think the same about Mason. YMMV
Anyway, the answer, for those who may wish to use the TT
burner, lies in
the way that TT evaluates list context. The story->list
method is never
evaluated in scalar context (due to TT internals) but TT
auto-vivifies
arrays into arrayrefs when there are more than one. This can
cause
problems when you have only one result because TT does not
turn this into
an arrayref. The canonical way to work around this in TT is
to call the
list vmethod on the scalar which turns it into a one element
list. Then
the size vmethod works as expected.
Unfortunately real methods take precedence over virtual ones
so calling
list on one ::Story object actually calls the ::Story::list
method (with
no arguments, returning all stories) instead of the list
vmethod.
Which is a bit suboptimal. We're still not quite sure what
the right way
around this is.
Simon.
--
Digital Craftsmen Ltd
Exmouth House, 3 Pine Street, bond. EC1R 0JH
t 020 7183 1410 f 020 7099 5140 m 07951 758698
w http://www.digitalcr
aftsmen.net/
|