[Templates] Comparing foo.first
Bill Moseley
moseley@hank.org
Wed, 16 Aug 2006 20:54:06 -0700
Must be time to quit for the day as this doesn't make sense, and I'm
sure it's very obvious.
I have template code that generates <th> elements based on a passed
in array. I set class tag on the <th> to indicate if it's a first,
middle or last column.
So, something like:
FOR column = headers;
col_pos = column == headers.first
? 'first'
: column == headers.last
? 'last'
: 'middle';
"<th class='$col_pos'>";
[...]
which has been working find. A added a new page today and noticed
that the first column was <th class='middle'>.
So I added a little debugging:
FOR column = headers;
col_pos = column == headers.first
? 'first'
: column == headers.last
? 'last'
: 'middle';
USE Dumper;
Dumper.dump( [ column, headers.first ] ) | stderr;
"value = $col_pos\n" | stderr;
And I get this:
$VAR1 = [
[
{
'order' => 'webcastdate',
'label' => 'Date'
}
],
[
{
'order' => 'webcastdate',
'label' => 'Date'
}
]
];
value = middle
$VAR1 = [
[
{
'order' => 'finaltitle',
'label' => 'Title'
}
],
[
{
'order' => 'webcastdate',
'label' => 'Date'
}
]
];
value = middle
Hum. Shouldn't headers.first be equal to one of the (the first) elements in the loop?
Here's the output I get when displaying a different table in the
application.
This time the first one matches:
$VAR1 = [
[
{
'order' => 'name',
'label' => 'Upcoming Events'
}
],
$VAR1->[0]
];
value = first
$VAR1 = [
[
{
'label' => 'Class Fee'
}
],
[
{
'order' => 'name',
'label' => 'Upcoming Events'
}
]
];
value = middle
$VAR1 = [
[
{
'label' => 'Note'
}
],
[
{
'order' => 'name',
'label' => 'Upcoming Events'
}
]
];
value = last
--
Bill Moseley
moseley@hank.org