2024-01-22 15:22:16 +00:00
|
|
|
package h
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2024-09-20 01:34:50 +00:00
|
|
|
"strings"
|
2024-09-11 00:52:18 +00:00
|
|
|
"time"
|
2024-01-22 15:22:16 +00:00
|
|
|
)
|
|
|
|
|
|
2024-09-21 16:52:56 +00:00
|
|
|
type Ren interface {
|
2024-09-22 15:46:38 +00:00
|
|
|
Render(context *RenderContext)
|
2024-09-21 16:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-20 01:24:44 +00:00
|
|
|
func Render(node Ren) string {
|
2024-09-11 00:52:18 +00:00
|
|
|
start := time.Now()
|
2024-09-20 01:34:50 +00:00
|
|
|
builder := &strings.Builder{}
|
2024-09-22 15:46:38 +00:00
|
|
|
context := &RenderContext{
|
|
|
|
|
builder: builder,
|
|
|
|
|
}
|
|
|
|
|
node.Render(context)
|
2024-09-11 00:52:18 +00:00
|
|
|
duration := time.Since(start)
|
2024-09-20 01:24:44 +00:00
|
|
|
fmt.Printf("render took %d microseconds\n", duration.Microseconds())
|
2024-09-20 01:34:50 +00:00
|
|
|
return builder.String()
|
2024-01-22 15:22:16 +00:00
|
|
|
}
|