Prepare reports for Promptkit migration
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Package reporttemplate provides embedded Markdown templates and schemas.
|
||||
// Package reporttemplate provides embedded Markdown templates and partials.
|
||||
package reporttemplate
|
||||
|
||||
import (
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
//go:embed templates/*.md.tmpl templates/partials/*.md.tmpl schemas/*.schema.json
|
||||
//go:embed templates/*.md.tmpl templates/partials/*.md.tmpl
|
||||
var assets embed.FS
|
||||
|
||||
var templates = map[string]string{
|
||||
@@ -25,13 +25,6 @@ var templatePartials = []string{
|
||||
"templates/partials/today_daypart_forecast.md.tmpl",
|
||||
}
|
||||
|
||||
var schemas = map[string]string{
|
||||
"daily": "schemas/daily.generated_text.schema.json",
|
||||
"hourly": "schemas/hourly.generated_text.schema.json",
|
||||
"today": "schemas/today.generated_text.schema.json",
|
||||
"tomorrow": "schemas/tomorrow.generated_text.schema.json",
|
||||
}
|
||||
|
||||
func Template(id string) (string, error) {
|
||||
path, ok := templates[id]
|
||||
if !ok {
|
||||
@@ -44,18 +37,6 @@ func Template(id string) (string, error) {
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
func Schema(id string) ([]byte, error) {
|
||||
path, ok := schemas[id]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unknown generated text schema %q", id)
|
||||
}
|
||||
data, err := assets.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read generated text schema %q: %w", id, err)
|
||||
}
|
||||
return append([]byte(nil), data...), nil
|
||||
}
|
||||
|
||||
func Render(id string, data any) ([]byte, error) {
|
||||
source, err := Template(id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user