package templates import "fmt" // List item templates const LIST_OPEN string = `` const TREE_VIEW_NAME string = `%s` // Generate a list of connections to display in the drop-down. // Current connection will be toggled as selected func ConnectionsList(connections map[string]string, current string) string { var html string = LIST_OPEN if len(connections) == 0 || connections == nil { html += fmt.Sprintf(LIST_ITEM, "", " selected", "No connections") return html + LIST_CLOSE } for name, url := range connections { if name == current { html += fmt.Sprintf(LIST_ITEM, url, " selected", name) } else { html += fmt.Sprintf(LIST_ITEM, url, "", name) } } treeName := fmt.Sprintf(TREE_VIEW_NAME, current) html += LIST_CLOSE return html + treeName }