[Templates] Flattening a hash
Bill Moseley
moseley@hank.org
Thu, 16 Feb 2006 16:53:45 -0800
How come when I search google for a problem I'm having the first hit
is where I asked the same question in the past? It's like my memory
has gone up in smoke.
http://template-toolkit.org/pipermail/templates/2001-December/002266.html
I'm generating an option list. The "options" method returns an
array ref of hashes.
But TT flattens it when there's only one element in the array.
So:
$VAR1 = [
{
'value' => '1',
'label' => 'Foo'
}
];
FOR i = field.options;
"<option value='$i.value'>";
i.label | html;
"</option>\n";
END;
Ends up like:
<option value="Foo"></option>
<option value="1"></option>
I thought the fix was .list, but nope. Must be too late in the day.
Er, the sky is falling...
BTW -- I just did a cvs update:
t/stash-xs............ok 1/66FAILED 34: - template text 11 did not match expected
t/stash-xs............NOK 34FAILED 52: - template text 20 did not match expected
t/stash-xs............NOK 52FAILED 54: - template text 21 did not match expected
t/stash-xs............FAILED tests 34, 52, 54
Failed 3/66 tests, 95.45% okay
t/stash...............ok 1/60FAILED 34: - template text 11 did not match expected
t/stash...............NOK 34FAILED 46: - template text 17 did not match expected
t/stash...............NOK 46FAILED 48: - template text 18 did not match expected
t/stash...............FAILED tests 34, 46, 48
Doesn't seem like a problem, but:
Stash.xs > Stash.xsc && mv Stash.xsc Stash.c
cc -c -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"2.14a\" -DXS_VERSION=\"2.14a\" -fPIC "-I/usr/lib/perl/5.8/CORE" Stash.c
In file included from Stash.xs:41:
ppport.h:356:1: warning: "PERL_UNUSED_DECL" redefined
In file included from Stash.xs:40:
/usr/lib/perl/5.8/CORE/perl.h:163:1: warning: this is the location of the previous definition
Running Mkbootstrap for Template::Stash::XS ()
Perl 5.8.8
--
Bill Moseley
moseley@hank.org