equal
deleted
inserted
replaced
34 |
34 |
35 // NewPrinterTemplate returns a Template ResourcePrinter |
35 // NewPrinterTemplate returns a Template ResourcePrinter |
36 // For TemplatePrinter, the options parameter contains the template string. |
36 // For TemplatePrinter, the options parameter contains the template string. |
37 func NewPrinterTemplate(options Options) (*TemplatePrinter, error) { |
37 func NewPrinterTemplate(options Options) (*TemplatePrinter, error) { |
38 tmpl := options["template"] |
38 tmpl := options["template"] |
|
39 if tmpl == "" { |
|
40 return nil, fmt.Errorf("empty template") |
|
41 } |
39 t, err := template.New("output").Funcs(template.FuncMap{ |
42 t, err := template.New("output").Funcs(template.FuncMap{ |
40 "fromhtml": html2string, |
43 "fromhtml": html2string, |
41 "fromunix": unix2string, |
44 "fromunix": unix2string, |
42 "color": ansiColor, |
45 "color": ansiColor, |
43 }).Parse(tmpl) |
46 }).Parse(tmpl) |