Having applied the methods at Debugging Template Toolkit I see that I'm passing my TT template:
DUMP: $VAR1 = { 'blist' => { 'Central600' => { 'checked' => 'on', 'curr' => 'off', 'desc' => 'Oregon 600-XTR, May 30-31 ' }, 'TriCities200' => { 'checked' => 'no', 'curr' => 'off', 'desc' => 'Tri-Cities 200, April 18 ' }, 'CoveredBridges400' => { 'checked' => 'on', 'curr' => 'yes', 'desc' => 'Covered Bridges 400, May 9' }, }, # end of %blist # other items }
And in my template file this:
Brevets spec'd manually [% blist.CoveredBridges400.desc %] [% blist.CoveredBridges400.curr %] [% blist.CoveredBridges400.checked %] end Brevets spec'd manually
yields the expected:
Brevets spec'd manually Covered Bridges 400, May 9 off on end Brevets spec'd manually
Yet when I try to access the hash values in some sort of FOREACH construct my lack of TT understanding mocks me by not yeilding up the desc, curr and checked values for each of the hashes in blist.
(This is the current of many iterations in trying to figure out what I don't yet know)
providing:[% FOREACH bb IN blist %] 4 bb $bb <br/> 5 bb.key $bb.key <br/> 6 blist.bb blist.$bb <br/> 7 bb.item desc $bb.key.item('desc')<br/> 7 blist.bb.keys blist.$bb.keys<br/> [% FOREACH bkey = blist.$bb.keys.shift %] [% bkey %] => [% # blist.$bb.$bkey %] [% END %] 7a blist.bb.vals blist.$bb.values<br/> [% FOREACH ba = blist.$bb.values.list %] [% ba %] [% END %] [% FOREACH ba IN blist.bb.values %] $ba [% END %] 8 [% blist.$bb.desc %] blist.($bb.key).desc or blist.bb.desc +<br/> 9 [% blist.$bb.curr %] blist.($bb.key).curr or blist.bb.curr +<br/> 10 [% blist.$bb.checked %] [% blist.$bb.key.checked %] <br/> [% END %]
4 bb HASH(0xd977f0) 5 bb.key CoveredBridges400 6 blist.bb blist.HASH(0xd977f0) 7 bb.item desc CoveredBridges400('desc') 7 blist.bb.keys blist.ARRAY(0xd8f730) 7a blist.bb.vals blist.ARRAY(0xd8f7b0) 8 blist.(CoveredBridges400).desc or blist.bb.desc 9 blist.(CoveredBridges400).curr or blist.bb.curr 10
In any case I'm not grokking how to walk trough the hash of hashes and extract the values.
So Monks, please take up your favorite cluesticks and beat the rocks that cover my understanding.
In reply to Hash of Hash Access in Template Toolkit by mikeraz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |