[Petal] Tree Tactics

Josh Narins josh at narins.net
Thu Sep 1 16:14:21 BST 2005


> I've got a tree, with arbitrary depth, like..
> 
> {
>   text => 'This is the top',
>   sort => [5,3,7],
>   children =>
>     3 => {
>           text => 'This should be second',
>           sort => [4,6],
>           children {
>              4 => { text=>'a leaf',},
>              4 => { text=>'another leaf',},
>           },
>     5 => ...
>     7 => ...
>   }
> }
> 
> I hope you get the idea.
> 
> How do I get this to work in Petal?
> 
> I figure I should be able to do it with a single template.
> 
> myself.xml
> ==========
> 
> <table>
>   <tr>
>     <td petal:content="object/text">
>      This is dummy text 
>     </td>
>     <td petal:repeat="SOMETHING HERE">
>      <xi:include href="./myself.xml" />
>     </td>
>   </tr>
> </table>
> 
> What should that repeat be? I can do it with "each:" but then I don't
> get any order. I want the order to be that as described in the sort
> array ref.
> 
> How does anyone handle recursive trees?

No one has recursive tips?




More information about the Petal mailing list