blob: 56d7d3a629b79cf10c7633db5339badb170ad2c6 (
plain) (
blame)
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
}
|