templates.go 579 B

12345678910111213141516171819202122232425262728
  1. package master_ui
  2. import (
  3. _ "embed"
  4. "html/template"
  5. "strings"
  6. )
  7. //go:embed master.html
  8. var masterHtml string
  9. //go:embed masterNewRaft.html
  10. var masterNewRaftHtml string
  11. var templateFunctions = template.FuncMap{
  12. "url": func(input string) string {
  13. if !strings.HasPrefix(input, "http://") && !strings.HasPrefix(input, "https://") {
  14. return "http://" + input
  15. }
  16. return input
  17. },
  18. }
  19. var StatusTpl = template.Must(template.New("status").Funcs(templateFunctions).Parse(masterHtml))
  20. var StatusNewRaftTpl = template.Must(template.New("status").Parse(masterNewRaftHtml))