github.com/sotirispl/buffalo@v0.11.1/render/xml.go (about) 1 package render 2 3 import ( 4 "encoding/xml" 5 "io" 6 ) 7 8 type xmlRenderer struct { 9 value interface{} 10 } 11 12 func (s xmlRenderer) ContentType() string { 13 return "application/xml" 14 } 15 16 func (s xmlRenderer) Render(w io.Writer, data Data) error { 17 enc := xml.NewEncoder(w) 18 enc.Indent("", " ") 19 return enc.Encode(s.value) 20 } 21 22 // XML renders the value using the "application/xml" 23 // content type. 24 func XML(v interface{}) Renderer { 25 return xmlRenderer{value: v} 26 } 27 28 // XML renders the value using the "application/xml" 29 // content type. 30 func (e *Engine) XML(v interface{}) Renderer { 31 return XML(v) 32 }