github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/internal/tprint.go (about) 1 package internal 2 3 import ( 4 "bytes" 5 "text/template" 6 ) 7 8 // Tprintf renders a string from a given template string and field values 9 func Tprintf(tmpl string, data map[string]interface{}) string { 10 t := template.Must(template.New("").Parse(tmpl)) 11 buf := &bytes.Buffer{} 12 if err := t.Execute(buf, data); err != nil { 13 return "" 14 } 15 return buf.String() 16 }