Ticket #7418 (new defect)
Active navigation items are broken in Clearsilver templates
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 0.11-retriage |
| Component: | general | Version: | 0.11-stable |
| Severity: | normal | Keywords: | clearsilver navigation |
| Cc: |
Description
It looks like changes made to move templates away from Clearsilver have introduced a regression where active navigation items are not highlighted properly.
To reproduce, use a plugin that returns a Clearsilver template from its process_request() method. You will see that the "mainnav" navigation bar does not render the active item highlighted.
The bug is that the CSS class "active" is not assigned to the list element in the navigation bar.
The fix is to change trac/web/chrome.py:
class Chrome(component)
...
def populate_hdf(self, req):
...
for category, items in req.chrome['nav'].items():
+ req.hdf['chrome.nav.%s' % category] = items
- for item in items:
- prefix = 'chrome.nav.%s.%s' % (category, item['name'])
- req.hdf[prefix] = item['label']
And then change trac/templates/header.cs:
<?cs def:nav(items) ?><?cs
if:len(items) ?><ul><?cs
set:idx = 0 ?><?cs
set:max = len(items) - 1 ?><?cs
each:item = items ?><?cs
set:first = idx == 0 ?><?cs
set:last = idx == max ?><li<?cs
if:first || last || item.active ?> class="<?cs
if:item.active ?>active<?cs /if ?><?cs
if:item.active && (first || last) ?> <?cs /if ?><?cs
if:first ?>first<?cs /if ?><?cs
if:(item.active || first) && last ?> <?cs /if ?><?cs
if:last ?>last<?cs /if ?>"<?cs
+ /if ?>><?cs var:item.label ?></li><?cs
- /if ?>><?cs var:item?></li><?cs
set:idx = idx + 1 ?><?cs
/each ?></ul><?cs
/if ?><?cs
/def ?>
Attachments
Change History
Note: See
TracTickets for help on using
tickets.


