-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.go
32 lines (29 loc) · 847 Bytes
/
ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package jaws
import (
"fmt"
"io"
"strings"
)
// If any of these functions panic, the Request will be closed and the panic logged.
// Optionally you may also implement ClickHandler and/or EventHandler.
type UI interface {
JawsRender(e *Element, w io.Writer, params []interface{}) error
JawsUpdate(e *Element)
}
func (rq *Request) JawsRender(elem *Element, w io.Writer, params []interface{}) (err error) {
if err = elem.ui.JawsRender(elem, w, params); err == nil {
if rq.Jaws.Debug {
var sb strings.Builder
_, _ = fmt.Fprintf(&sb, "<!-- id=%q %T tags=[", elem.jid, elem.ui)
for i, tag := range elem.Request.TagsOf(elem) {
if i > 0 {
sb.WriteString(", ")
}
sb.WriteString(TagString(tag))
}
sb.WriteByte(']')
_, _ = w.Write([]byte(strings.ReplaceAll(sb.String(), "-->", "==>") + " -->"))
}
}
return
}