List Info

Thread: closing a nested list correctly on the last item




closing a nested list correctly on the last item
user name
2006-05-31 13:42:18

> -----Original Message-----
> From: Stephen Stewart [mailto:Stephen.Stewartdesignbyfront.com]
> Sent: 31 May 2006 14:22
> To: templatestemplate-toolkit.org
> Subject: [Templates] closing a nested list correctly on
the last item
> 
> 
> Hello,
> 
> I've been using the examples in the badger book for 
> navigation elements
> built from an XML sitemap. In my case I've been trying
to build the
> navigation with an HTML list:
> 
> <ul>
>   <li>apples</li>
>   <li>oranges</li>
>     <ul>
>       <li>clementine</li>
>       <li>mandarin</li>
>       <li>satsuma</li>
>       <li>tangerine</li>
>     </ul>
> </ul>
> 
> However I have a problem when the last item in the
outer list has sub
> items in the version I've created. If I use loop.last
in 
> menu/nest (from
> the Badger Book example) the outer <ul> will
close before the 
> inner <ul>
> is built:
> 
> <ul>
>   <li>apples</li>
>   <li>oranges</li>
> </ul>
>     <ul>
>       <li>clementine</li>
>       <li>mandarin</li>
>       <li>satsuma</li>
>       <li>tangerine</li>
>     </ul>
> 
> My menu/nest:
> [% IF loop.first %]
> <ul>
> [%- END -%]
> 
> <li [% IF loop.first %]class="first"[%-
END -%] [% IF loop.last &&
> !loop.first %]class="last"[%- END
-%]><a href="[% link.url %]"
> [%- " class=\"$link.class\""
>   IF link.class
> -%]><span>[%- link.text -%]
</span></a></li>
> [% IF loop.last %]
> </ul>
> [%- END -%]
> 

Can you give more of your template please. Could you include
the FOREACH and matching END directives. The normal way of
approaching what you want is to nest loops.

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )