helper.go 714 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package test
  2. import (
  3. "html/template"
  4. "time"
  5. "github.com/gofiber/fiber/v2"
  6. "github.com/gofiber/template/html"
  7. )
  8. const (
  9. testVersion = "1"
  10. testGA = false
  11. )
  12. func GetFiberConfig() fiber.Config {
  13. engine := html.New("./../../templates", ".html")
  14. // nolint:gocritic
  15. engine.AddFunc("now", func() time.Time {
  16. return time.Now()
  17. })
  18. // nolint:gosec
  19. engine.AddFunc("noescape", func(str string) template.HTML {
  20. return template.HTML(str)
  21. })
  22. engine.AddFunc("gridsep", func(i, l int) bool {
  23. i++
  24. return i%3 == 0 && i != l
  25. })
  26. engine.AddFunc("version", func() string {
  27. return testVersion
  28. })
  29. engine.AddFunc("ga", func() bool {
  30. return testGA
  31. })
  32. return fiber.Config{
  33. Views: engine,
  34. }
  35. }