action.go 905 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package element
  2. import (
  3. "git.nspix.com/golang/pgenr/internal/pool"
  4. "golang.org/x/net/html/atom"
  5. "html"
  6. )
  7. type Action struct {
  8. Instructions Element
  9. Button *Button
  10. InviteCode string
  11. }
  12. func (element *Action) Html() string {
  13. return element.String()
  14. }
  15. func (element *Action) String() string {
  16. br := pool.Get()
  17. defer pool.Put(br)
  18. if element.Instructions != nil {
  19. br.WriteString(element.Instructions.Html())
  20. }
  21. br.WriteString(beginTag(atom.Div.String(), Attrs{"class": "action-block"}))
  22. if element.InviteCode != "" {
  23. br.WriteString(beginTag(atom.Span.String(), Attrs{"class": "invite-code"}))
  24. br.WriteString(html.EscapeString(element.InviteCode))
  25. br.WriteString(endTag(atom.Span.String()))
  26. }
  27. if element.Button != nil {
  28. br.WriteString(element.Button.String())
  29. }
  30. br.WriteString(endTag(atom.Div.String()))
  31. return br.String()
  32. }
  33. func NewAction() *Action {
  34. return &Action{}
  35. }