stylerule.go 365 B

123456789101112131415161718192021
  1. package css
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. type CSSStyleRule struct {
  7. Selector *CSSValue
  8. Styles []*CSSStyleDeclaration
  9. }
  10. func (sr *CSSStyleRule) Text() string {
  11. decls := make([]string, 0, len(sr.Styles))
  12. for _, s := range sr.Styles {
  13. decls = append(decls, s.Text())
  14. }
  15. return fmt.Sprintf("%s {\n%s\n}", sr.Selector.Text(), strings.Join(decls, ";\n"))
  16. }