Files

29 lines
718 B
Go
Raw Permalink Normal View History

2026-08-21 15:58:46 -07:00
package prompts
import (
"embed"
"fmt"
"strings"
"text/template"
)
//go:embed planner/default.tmpl judge/default.tmpl implementer/default.tmpl
var templates embed.FS
// Render renders a template with the given variables.
func Render(templateRef string, variables map[string]any) (string, error) {
// Load template from embedded files
tmpl, err := template.ParseFS(templates, templateRef)
if err != nil {
return "", fmt.Errorf("failed to parse template %s: %w", templateRef, err)
}
// Render the template
var result strings.Builder
if err := tmpl.Execute(&result, variables); err != nil {
return "", fmt.Errorf("failed to render template %s: %w", templateRef, err)
}
return result.String(), nil
}