-
-
Notifications
You must be signed in to change notification settings - Fork 366
Expand file tree
/
Copy pathflush.go
More file actions
36 lines (30 loc) · 576 Bytes
/
Copy pathflush.go
File metadata and controls
36 lines (30 loc) · 576 Bytes
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
33
34
35
36
package templ
import (
"context"
"io"
)
// Flush flushes the output buffer after all its child components have been rendered.
func Flush() FlushComponent {
return FlushComponent{}
}
type FlushComponent struct {
}
type flusherError interface {
Flush() error
}
type flusher interface {
Flush()
}
func (f FlushComponent) Render(ctx context.Context, w io.Writer) (err error) {
if err = GetChildren(ctx).Render(ctx, w); err != nil {
return err
}
switch w := w.(type) {
case flusher:
w.Flush()
return nil
case flusherError:
return w.Flush()
}
return nil
}