MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / writeAttrsTo

Method writeAttrsTo

xmlparser/tokens.go:47–76  ·  view source on GitHub ↗

writeAttrsTo writes the attributes of the start element to the provided writer.

(w TokenWriter)

Source from the content-addressed store, hash-verified

45
46// writeAttrsTo writes the attributes of the start element to the provided writer.
47func (e *StartElement) writeAttrsTo(w TokenWriter) error {
48 for attr := range e.Attrs.Iter() {
49 if err := w.WriteByte(' '); err != nil {
50 return err
51 }
52
53 quote := byte('"')
54 if strings.IndexByte(attr.Value, quote) != -1 {
55 quote = '\''
56 }
57
58 if _, err := w.WriteString(attr.Name.String()); err != nil {
59 return err
60 }
61 if err := w.WriteByte('='); err != nil {
62 return err
63 }
64 if err := w.WriteByte(quote); err != nil {
65 return err
66 }
67 if _, err := w.WriteString(attr.Value); err != nil {
68 return err
69 }
70 if err := w.WriteByte(quote); err != nil {
71 return err
72 }
73 }
74
75 return nil
76}
77
78// EndElement represents an end element token (e.g., </tag>).
79type EndElement struct {

Callers 1

WriteToMethod · 0.95

Calls 3

IterMethod · 0.80
WriteByteMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected