[Petal] bug, or misunderstanding?

Corey corey_s at qwest.net
Thu Apr 20 06:28:29 BST 2006


'Nother question!

Trying to iterate through one hash, then use its keys to get values from a
second hash.


$data = {

  'foo' =>  {
     'boat' => 'FOO_val_boat',
     'car'  => 'FOO_val_car',
  },

  'bar' =>  {
     'boat' => 'BAR_val_boat',
     'car'  => 'BAR_val_car',
  },

};


doesn't work:
<div petal:repeat="field each: data/foo"> <!-- iter through %{ $data->{foo} } -->
 <span petal:replace="data/bar/string:${data/foo}"> doesn't work! why not? </span>
</div>


works:
<div petal:repeat="field each: data/foo"> <!-- iter through %{ $data->{foo} } -->
 <span petal:define="var field/key"> $var equals "boat"</span>
 <span petal:replace="data/bar/string:${var}"> results in "BAR_val_boat" </span>
</div>


I'd prefer the second version to the first, as the first version seems as though
it should be unnecessary.

What is it about the ${blah} vs. ${data/foo} syntax? Or is it something special
that goes on when I create/define the temporary variable, var? Is there a bug
in the way replace scans/parses the string, and so gets confused with the '/'
that's in the ${} interpolation?


Thanks!

Corey


More information about the Petal mailing list