All,
I have a data structure like this:
And want Template Toolkit to output the data in the following format:$favouritesMenu = [ { 'name' => 'Mobility Solutions', 'id' => '00021', 'children' => [] }, { 'name' => 'Rob', 'id' => '00030', 'children' => [ { 'name' => 'Mobility Solutions', 'id' => '00021', 'children' => [ { 'name' => 'RSA SecurID/Remote VPN New User + Request - Self', 'id' => '00032', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN New User + Request - Other', 'id' => '00039', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN Expiry', 'id' => '00044', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN Dormancy +', 'id' => '00040', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN Delete', 'id' => '00041', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN Existing + User', 'id' => '00046', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN Challeng +e and Response (ID&V) Details', 'id' => '00045', 'children' => [] }, { 'name' => 'RSA SecurID/Remote VPN Third Pa +rty Request', 'id' => '00042', 'children' => [] }, { 'name' => 'Broadband Request - Home, Offic +e & Branch', 'id' => '00043', 'children' => [] } ] } ] } ];
<ul> <li>Mobility Solutions</li> <li> Rob <ul> <li> Mobility Solutions <ul> <li>RSA SecurID/Remote VPN New User Request - Self +</li> <li>RSA SecurID/Remote VPN New User Request - Othe +r</li> <li>RSA SecurID/Remote VPN Expiry</li> <li>RSA SecurID/Remote VPN Dormancy</li> <li>RSA SecurID/Remote VPN Delete</li> <li>RSA SecurID/Remote VPN Existing User</li> <li>RSA SecurID/Remote VPN Challenge and Response +(ID&V) Details</li> <li>RSA SecurID/Remote VPN Third Party Request</li +> <li>Broadband Request - Home, Office & Branch< +/li> </ul> </li> </ul> </li> </ul>
I'm guessing that because I had to use a recursive sub to create the data structure I'm going to have to use something similar to output the data.
Many thanks
Rob
In reply to Recursion in Template::Toolkit by purinkle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |