package main
import (
"bytes"
"text/template"
)
func GenerateEpisodeDescription(imageURL, title, content string) string {
// Template con sezione CDATA
const descTemplate = `
{{if .ImageURL}}

{{end}}
{{.Title}}
{{.Content}}
`
// Dati per il template
data := struct {
ImageURL string
Title string
Content string
}{
ImageURL: imageURL,
Title: title,
Content: content,
}
// Esecuzione del template
var buf bytes.Buffer
tmpl := template.Must(template.New("desc").Parse(descTemplate))
if err := tmpl.Execute(&buf, data); err != nil {
// Fallback con CDATA
return "" + title + "
" + content + ">"
}
return buf.String()
}