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 14:27:26
Hi,
 
Larry wrote (31/05/2006):
> I think this should probably be:
> 
>    <ul>
>     <li>apples</li>
>     <li>oranges
>       <ul>
>         <li>clementine</li>
>         <li>mandarin</li>
>         <li>satsuma</li>
>         <li>tangerine</li>
>       </ul>
>     </li>
>    </ul>

You're right. The O'Reilly HTML & XHTML Definitive
Guide sent me down
the wrong path there.

IvorW wrote (31/05/2006):
> 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.

This is menu/nest,

[%  DEFAULT pad = '';
    DEFAULT level = 1;

    FOREACH item = menu.items;
        pad;

        UNLESS notoplevel && level == 1;
            INCLUDE menu/text
                link = {
                   text     = item.name
                   url      = item.url
                   class    = item.hot ? 'menuselect' :
'menu'
                 };
        END;

        IF item.subs && !norecur;
            INCLUDE menu/nest
              level = level + 1
              menu = item
              pad  = pad ? ""
                         : "";
        END;

    END
-%]

which uses menu/text,

[% 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 -%]

Maybe I shouldn't be using this example at all to do this?

Stephen

--
FRONT
http://www.designbyfront
.com





_______________________________________________
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 )