{% import "github.com/bouncepaw/mycorrhiza/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "sort" %} {% code var hyphaListL10n = map[string]l10nEntry{ "heading": en("List of users").ru("Список пользователей"), "administrators": en("Administrators").ru("Администраторы"), "moderators": en("Moderators").ru("Модераторы"), "editors": en("Editors").ru("Редакторы"), } %} {% func UserListHTML(lc *l18n.Localizer) %}
{% code var get = func(key string) string { return hyphaListL10n[key].get(lc.Locale) } var ( admins = make([]string, 0) moderators = make([]string, 0) editors = make([]string, 0) ) for u := range user.YieldUsers() { switch u.Group { // What if we place the users into sorted slices? case "admin": admins = append(admins, u.Name) case "moderator": moderators = append(moderators, u.Name) case "editor", "trusted": editors = append(editors, u.Name) } } sort.Strings(admins) sort.Strings(moderators) sort.Strings(editors) %}

{%s get("heading") %}

{%s get("administrators") %}

    {% for _, name := range admins %}
  1. {%s name %}
  2. {% endfor %}

{%s get("moderators") %}

    {% for _, name := range moderators %}
  1. {%s name %}
  2. {% endfor %}

{%s get("editors") %}

    {% for _, name := range editors %}
  1. {%s name %}
  2. {% endfor %}
{% endfunc %}