Skip to content

Commit

Permalink
html element setters to return the element
Browse files Browse the repository at this point in the history
  • Loading branch information
maxence-charriere committed Oct 3, 2023
1 parent c063b65 commit 57ae52e
Show file tree
Hide file tree
Showing 4 changed files with 1,685 additions and 13 deletions.
18 changes: 18 additions & 0 deletions pkg/app/gen/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -2342,12 +2342,30 @@ func writeStruct(w io.Writer, t tag) {
fmt.Fprintln(w)

fmt.Fprintf(w, `
func (e *html%s) setDepth(v uint) UI {
e.depth = v
return e
}
func (e *html%s) setJSElement(v Value) HTML {
e.jsElement = v
return e
}
func (e *html%s) setAttrs(v attributes) HTML {
e.attributes = v
return e
}
func (e *html%s) setParent(v UI) UI {
e.parentElement = v
return e
}
`,
t.Name,
t.Name,
t.Name,
t.Name,
)
}

Expand Down
13 changes: 3 additions & 10 deletions pkg/app/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ type HTML interface {
Depth() uint

attrs() attributes
setAttrs(attributes) HTML
events() eventHandlers
setDepth(uint)
setJSElement(Value)
setDepth(uint) UI
setJSElement(Value) HTML
parent() UI
body() []UI
}
Expand Down Expand Up @@ -432,14 +433,6 @@ func (e *htmlElement) events() eventHandlers {
return e.eventHandlers
}

func (e *htmlElement) setDepth(v uint) {
e.depth = v
}

func (e *htmlElement) setJSElement(v Value) {
e.jsElement = v
}

func (e *htmlElement) parent() UI {
return e.parentElement
}
Expand Down
Loading

0 comments on commit 57ae52e

Please sign in to comment.