helper_method_css.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package ace
  2. import (
  3. "bytes"
  4. "io"
  5. )
  6. // helperMethodCSS represents a helper method css.
  7. type helperMethodCSS struct {
  8. elementBase
  9. }
  10. // WriteTo writes data to w.
  11. func (e *helperMethodCSS) WriteTo(w io.Writer) (int64, error) {
  12. var bf bytes.Buffer
  13. // Write an open tag.
  14. bf.WriteString(lt)
  15. bf.WriteString(`style type="text/css"`)
  16. bf.WriteString(gt)
  17. bf.WriteString(lf)
  18. // Write the children's HTML.
  19. if i, err := e.writeChildren(&bf); err != nil {
  20. return i, err
  21. }
  22. // Write an open tag.
  23. bf.WriteString(lt)
  24. bf.WriteString(slash)
  25. bf.WriteString("style")
  26. bf.WriteString(gt)
  27. // Write the buffer.
  28. i, err := w.Write(bf.Bytes())
  29. return int64(i), err
  30. }
  31. // ContainPlainText returns true.
  32. func (e *helperMethodCSS) ContainPlainText() bool {
  33. return true
  34. }
  35. // helperMethodCSS creates and returns a helper method css.
  36. func newHelperMethodCSS(ln *line, rslt *result, src *source, parent element, opts *Options) *helperMethodCSS {
  37. return &helperMethodCSS{
  38. elementBase: newElementBase(ln, rslt, src, parent, opts),
  39. }
  40. }