You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
969 B

10 years ago
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package base
  5. import (
  6. "container/list"
  7. "html/template"
  8. )
  9. func Str2html(raw string) template.HTML {
  10. return template.HTML(raw)
  11. }
  12. func Range(l int) []int {
  13. return make([]int, l)
  14. }
  15. func List(l *list.List) chan interface{} {
  16. e := l.Front()
  17. c := make(chan interface{})
  18. go func() {
  19. for e != nil {
  20. c <- e.Value
  21. e = e.Next()
  22. }
  23. close(c)
  24. }()
  25. return c
  26. }
  27. var TemplateFuncs template.FuncMap = map[string]interface{}{
  28. "AppName": func() string {
  29. return AppName
  30. },
  31. "AppVer": func() string {
  32. return AppVer
  33. },
  34. "AppDomain": func() string {
  35. return Domain
  36. },
  37. "AvatarLink": AvatarLink,
  38. "str2html": Str2html,
  39. "TimeSince": TimeSince,
  40. "FileSize": FileSize,
  41. "Subtract": Subtract,
  42. "ActionIcon": ActionIcon,
  43. "ActionDesc": ActionDesc,
  44. "DateFormat": DateFormat,
  45. "List": List,
  46. }