We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element should have a Create method or similar, to allow for more natural creation of nested values
doc := NewDocument() doc.Create("People", func(e *Element) { e.Create("Person", func(e *Element) { e.CreateAttr("name", "Jon") }) e.Create("Person", func(e *Element) { e.CreateAttr("name", "Sally") }) })
The text was updated successfully, but these errors were encountered:
implementation
package etree func (e *Element) Create(tag string, f func(*Element)) { f(e.CreateElement(tag)) }
Sorry, something went wrong.
in case this is not accepted, here is a wrapper:
package etree import "github.com/beevik/etree" type Document struct { *etree.Document } func NewDocument() *Document { var d Document d.Document = etree.NewDocument() return &d } func (d Document) Element() *Element { return &Element{&d.Document.Element} } type Element struct { *etree.Element } func (e *Element) Create(tag string, f func(*Element)) { f(&Element{ e.Element.CreateElement(tag), }) }
No branches or pull requests
Element should have a Create method or similar, to allow for more natural creation of nested values
The text was updated successfully, but these errors were encountered: