[Petal] bug, or misunderstanding?

Corey corey_s at qwest.net
Thu Apr 20 06:52:38 BST 2006


On Wednesday 19 April 2006 22:28, Corey wrote:
<snip>
> <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>
> 
<snip>
> What is it about the ${blah} vs. ${data/foo} syntax?
<snip>


I said "${data/foo}", when I meant "${field/key}" ...  shouldn't be posting when I'm 
so tired... sorry!

Here's my post, with no errors this time:

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:${field/key}"> 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 first version to the second, as the second version seems as though
it should be unnecessary.

What is it about the ${blah} vs. ${field/key} 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!




More information about the Petal mailing list