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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| {% import ( "strings"
"{{{ .Package }}}/app/controller/cmenu" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/lib/menu" "{{{ .Package }}}/views/components" "{{{ .Package }}}/views/vutil" ) %}
{% func Menu(ps *cutil.PageState) %}{% stripspace %} {% if len(ps.Menu) > 0 %} <div class="menu-container"> {%= vutil.Indent(true, 2) %} <div class="menu"> {%= vutil.Indent(true, 3) %} <ul class="level-0"> {% for _, i := range ps.Menu %} {%= MenuItem(i, []string{}, ps.Breadcrumbs, 3, ps) %} {% endfor %} {%= vutil.Indent(true, 3) %} </ul> {%= vutil.Indent(true, 2) %} </div> {%= vutil.Indent(true, 1) %} </div> {% endif %} {% endstripspace %}{% endfunc %}
{% func MenuItem(i *menu.Item, path []string, breadcrumbs cmenu.Breadcrumbs, indent int, ps *cutil.PageState) %}{% stripspace %} {% code path = append(path, i.Key) active, final := breadcrumbs.Active(i, path) %} {% if i.Key == "" %} {%= vutil.Indent(true, indent + 1) %} <li class="separator"></li> {% elseif len(i.Children) > 0 %} {% code itemID := strings.Join(path, "--")%} {%= vutil.Indent(true, indent + 1) %} {% if active %}<li class="active" data-menu-key="{%s i.Key %}">{% else %}<li data-menu-key="{%s i.Key %}">{% endif %} {%= vutil.Indent(true, indent + 2) %} <input id="{%s itemID %}-input" type="checkbox"{% if active %}{% space %}checked="checked"{% endif %}{% space %}hidden /> {%= vutil.Indent(true, indent + 2) %} {% if final %}<label class="final" for="{%s itemID %}-input" title="{%s i.Desc() %}">{% else %}<label for="{%s itemID %}-input" title="{%s i.Desc() %}">{% endif %} {% if i.Route != "" %} {%= vutil.Indent(true, indent + 3) %} <a class="label-link" href="{%s i.Route %}">{%= components.SVGRef(`link`, 15, 15, ``, ps) %}</a> {% endif %} {%= components.ExpandCollapse(indent + 3, ps) %} {% if i.Badge != "" %} {%= vutil.Indent(true, indent + 3) %} <div class="badge">{%s i.Badge %}</div> {% endif %} {%= vutil.Indent(true, indent + 3) %} {% if i.Icon != "" %} {%= components.SVGRef(i.Icon, 16, 16, "icon", ps) %} {% endif %} {% if i.Route != "" %} <a href="{%s i.Route %}">{%s i.Title %}</a> {% else %} {%s i.Title %} {% endif %} {%= vutil.Indent(true, indent + 2) %} </label> {%= vutil.Indent(true, indent + 2) %} <div class="menu-content level-{%d len(path) %}"> {%= vutil.Indent(true, indent + 3) %} <ul> {% for _, i := range i.Children %} {%= MenuItem(i, path, breadcrumbs, indent + 3, ps) %} {% endfor %} {%= vutil.Indent(true, indent + 3) %} </ul> {%= vutil.Indent(true, indent + 2) %} </div> {%= vutil.Indent(true, indent + 1) %} </li> {% else %} {% code finalClass := "item" if active { finalClass += " active" } if final { finalClass += " final" } %} {%= vutil.Indent(true, indent + 1) %} <li data-menu-key="{%s i.Key %}"> <a class="{%s finalClass %}" href="{%s i.Route %}" title="{%s i.Desc() %}"> {% if i.Badge != "" %} {%= vutil.Indent(true, indent + 3) %} <div class="badge">{%s i.Badge %}</div> {% endif %} {% if i.Icon != "" %} {%= components.SVGRef(i.Icon, 16, 16, "icon", ps) %} {% endif %} {%s i.Title %} </a> </li> {% endif %} {% endstripspace %}{% endfunc %}
|