I assume that you are passing the Moose object this way.
$template->process('some.tt', $moose_object, ... );
The second parameter is considered a hehref, and not some blissful object (moose or not).
So, the Moose object is treated as a simple hash and has no βcolorβ key until you populate it by calling Accessor outside the Template Toolkit.
You need to do something like this:
$template->process('some.tt', { obj => $moose_object }, ... );
And then in your template:
[% FOREACH color IN obj.colors %] ... [% END %]
Which should work the way you expect.
source share