printer/templateprinter.go
changeset 41 909c3ddd83f6
parent 40 ad148f60dc87
child 49 d6b4e3b7c6c6
equal deleted inserted replaced
40:ad148f60dc87 41:909c3ddd83f6
    26 
    26 
    27 // NewPrinterTemplate returns a Template ResourcePrinter
    27 // NewPrinterTemplate returns a Template ResourcePrinter
    28 // For TemplatePrinter, the option parameter contains the template string.
    28 // For TemplatePrinter, the option parameter contains the template string.
    29 func NewPrinterTemplate(option string) (*TemplatePrinter, error) {
    29 func NewPrinterTemplate(option string) (*TemplatePrinter, error) {
    30 	tmpl := option
    30 	tmpl := option
    31 	t, err := template.New("output").Funcs(template.FuncMap{"fromhtml": html2string}).Parse(tmpl)
    31 	t, err := template.New("output").Funcs(template.FuncMap{
       
    32 		"fromhtml": html2string,
       
    33 		"fromunix": unix2string,
       
    34 	}).Parse(tmpl)
    32 	if err != nil {
    35 	if err != nil {
    33 		return nil, err
    36 		return nil, err
    34 	}
    37 	}
    35 	return &TemplatePrinter{
    38 	return &TemplatePrinter{
    36 		rawTemplate: tmpl,
    39 		rawTemplate: tmpl,