Core

/app/controller/cmenu/breadcrumbs.go (515 B)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cmenu

import (
"{{{ .Package }}}/app/lib/menu"
)

type Breadcrumbs []string

func (b Breadcrumbs) Active(i *menu.Item, path []string) (bool, bool) {
for idx, x := range path {
if len(b) <= idx || b[idx] != x {
return false, false
}
}
if len(i.Children) == 0 {
return true, true
}
if len(path) == len(b) {
return true, true
}
if len(path) < len(b) {
next := b[len(path)]
for _, kid := range i.Children {
if kid.Key == next {
return true, false
}
}
}
return true, true
}