[Petal] Is even/odd working in the current version?
Jonathan Vanasco
petal-list at 2xlp.com
Wed Feb 1 17:17:00 GMT 2006
That's pretty much self explanatory
This is in the docs:
=pod
<table>
<div
tal:omit-tag=""
tal:repeat="audience self/audiences"
>
<tr
class="odd"
tal:condition="true: audience/odd"
>
<td>
This a odd row, it comes before the even row.
</td>
</tr>
<tr
class="even"
tal:condition="true: audience/even"
>
<td>
This a even row.
</td>
</tr>
</div>
</table>
=cut
i'm getting false for both even and odd
i tried addressing it as even/odd on its own - still no luck
i jumped into the cache to get an idea of what was going on:
(note, i stripped out the non-even odd stuff)
from what I see, it seems to be storing the data in a user defined
named hash, and operating instructions/details in other hashes
( repeat, even, odd)
but then its calling get_encoded,the normal function
i couldn't find anything that either:
stores even/odd into the hash itself
a line in get_encoded fetch or __FETCH that checks the other hashes
for special things (other than the modifiers)
so i'm left wondering if its broken or if i'm just completely inept
with this
can anyone suggest/confirm for me ?
my @array = @{$hash->get ('Audiences')};
for (my $i=0; $i < @array; $i++)
{
my $hash = $hash->new();
my $number = $i + 1;
my $odd = $number % 2;
my $even = $i % 2;
my $start = ($i == 0);
my $end = ($i == $#array);
my $inner = ($i and $i < @array);
$hash->{__count__} = $number;
$hash->{__is_first__} = $start;
$hash->{__is_last__} = $end;
$hash->{__is_inner__} = $inner;
$hash->{__even__} = $even;
$hash->{__odd__} = $odd;
$hash->{repeat} =
{
index => $i,
number => $number,
even => $even,
odd => $odd,
$hash->{__is_last__} = $end;
$hash->{__is_inner__} = $inner;
$hash->{__even__} = $even;
$hash->{__odd__} = $odd;
$hash->{repeat} =
{
index => $i,
number => $number,
even => $even,
odd => $odd,
start => $start,
end => $end,
inner => $inner,
};
$hash->{'audience'} = $array[$i];
$res .= "";
if ($hash->get ('false:string:1'))
{
$res .= "\<div\>";
};
$res .= "\
\ \ \<div\>\[\<span\>";
$res .= do {
my $res = $hash->get_encoded ('audience/name');
(defined $res) ? $res : "";
};
$res .= "\<\/span\>\ \=\ \<span\>";
$res .= do {
my $res = $hash->get_encoded ('audience/even');
(defined $res) ? $res : "";
};
$res .= "\<\/span\>\ \=\ \<span\>";
$res .= do {
my $res = $hash->get_encoded ('audience/odd');
(defined $res) ? $res : "";
};
$res .= "\<\/span\>\ \]\<\/div\>\
More information about the Petal
mailing list