summaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/a-h/templ/runtime
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-09-13 13:01:48 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-09-13 13:01:48 +0200
commit548090e67f66acf84385c4152ca464e52d3e3319 (patch)
tree9b6de528bd7b0aa63362fa83f5c8e6a97f68a5d8 /vendor/github.com/a-h/templ/runtime
parenta1d809960bee74df19c7e5fc34ffd1e4757cfdcb (diff)
Migrate away from templ and towards html/template
Diffstat (limited to 'vendor/github.com/a-h/templ/runtime')
-rw-r--r--vendor/github.com/a-h/templ/runtime/buffer.go62
-rw-r--r--vendor/github.com/a-h/templ/runtime/bufferpool.go38
-rw-r--r--vendor/github.com/a-h/templ/runtime/builder.go8
-rw-r--r--vendor/github.com/a-h/templ/runtime/runtime.go21
4 files changed, 0 insertions, 129 deletions
diff --git a/vendor/github.com/a-h/templ/runtime/buffer.go b/vendor/github.com/a-h/templ/runtime/buffer.go
deleted file mode 100644
index 63e4acd..0000000
--- a/vendor/github.com/a-h/templ/runtime/buffer.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package runtime
-
-import (
- "bufio"
- "io"
- "net/http"
-)
-
-// DefaultBufferSize is the default size of buffers. It is set to 4KB by default, which is the
-// same as the default buffer size of bufio.Writer.
-var DefaultBufferSize = 4 * 1024 // 4KB
-
-// Buffer is a wrapper around bufio.Writer that enables flushing and closing of
-// the underlying writer.
-type Buffer struct {
- Underlying io.Writer
- b *bufio.Writer
-}
-
-// Write the contents of p into the buffer.
-func (b *Buffer) Write(p []byte) (n int, err error) {
- return b.b.Write(p)
-}
-
-// Flush writes any buffered data to the underlying io.Writer and
-// calls the Flush method of the underlying http.Flusher if it implements it.
-func (b *Buffer) Flush() error {
- if err := b.b.Flush(); err != nil {
- return err
- }
- if f, ok := b.Underlying.(http.Flusher); ok {
- f.Flush()
- }
- return nil
-}
-
-// Close closes the buffer and the underlying io.Writer if it implements io.Closer.
-func (b *Buffer) Close() error {
- if c, ok := b.Underlying.(io.Closer); ok {
- return c.Close()
- }
- return nil
-}
-
-// Reset sets the underlying io.Writer to w and resets the buffer.
-func (b *Buffer) Reset(w io.Writer) {
- if b.b == nil {
- b.b = bufio.NewWriterSize(b, DefaultBufferSize)
- }
- b.Underlying = w
- b.b.Reset(w)
-}
-
-// Size returns the size of the underlying buffer in bytes.
-func (b *Buffer) Size() int {
- return b.b.Size()
-}
-
-// WriteString writes the contents of s into the buffer.
-func (b *Buffer) WriteString(s string) (n int, err error) {
- return b.b.WriteString(s)
-}
diff --git a/vendor/github.com/a-h/templ/runtime/bufferpool.go b/vendor/github.com/a-h/templ/runtime/bufferpool.go
deleted file mode 100644
index ca2a131..0000000
--- a/vendor/github.com/a-h/templ/runtime/bufferpool.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package runtime
-
-import (
- "io"
- "sync"
-)
-
-var bufferPool = sync.Pool{
- New: func() any {
- return new(Buffer)
- },
-}
-
-// GetBuffer creates and returns a new buffer if the writer is not already a buffer,
-// or returns the existing buffer if it is.
-func GetBuffer(w io.Writer) (b *Buffer, existing bool) {
- if w == nil {
- return nil, false
- }
- b, ok := w.(*Buffer)
- if ok {
- return b, true
- }
- b = bufferPool.Get().(*Buffer)
- b.Reset(w)
- return b, false
-}
-
-// ReleaseBuffer flushes the buffer and returns it to the pool.
-func ReleaseBuffer(w io.Writer) (err error) {
- b, ok := w.(*Buffer)
- if !ok {
- return nil
- }
- err = b.Flush()
- bufferPool.Put(b)
- return err
-}
diff --git a/vendor/github.com/a-h/templ/runtime/builder.go b/vendor/github.com/a-h/templ/runtime/builder.go
deleted file mode 100644
index 0f4c9d4..0000000
--- a/vendor/github.com/a-h/templ/runtime/builder.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package runtime
-
-import "strings"
-
-// GetBuilder returns a strings.Builder.
-func GetBuilder() (sb strings.Builder) {
- return sb
-}
diff --git a/vendor/github.com/a-h/templ/runtime/runtime.go b/vendor/github.com/a-h/templ/runtime/runtime.go
deleted file mode 100644
index aaa4a2c..0000000
--- a/vendor/github.com/a-h/templ/runtime/runtime.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package runtime
-
-import (
- "context"
- "io"
-
- "github.com/a-h/templ"
-)
-
-// GeneratedComponentInput is used to avoid generated code needing to import the `context` and `io` packages.
-type GeneratedComponentInput struct {
- Context context.Context
- Writer io.Writer
-}
-
-// GeneratedTemplate is used to avoid generated code needing to import the `context` and `io` packages.
-func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component {
- return templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
- return f(GeneratedComponentInput{ctx, w})
- })
-}