New creates a new Render instance with default templates and helper functions.
()
| 23 | |
| 24 | // New creates a new Render instance with default templates and helper functions. |
| 25 | func New() *Render { |
| 26 | r := Render{ |
| 27 | tmpls: template.New("render").Funcs(map[string]interface{}{ |
| 28 | "Field": fieldName, |
| 29 | "Receiver": receiverName, |
| 30 | "Param": parameterName, |
| 31 | "Want": wantName, |
| 32 | "Got": gotName, |
| 33 | "TypeArgs": typeArguments, |
| 34 | "FieldType": fieldType, |
| 35 | "ReceiverType": receiverType, |
| 36 | }), |
| 37 | } |
| 38 | |
| 39 | // default templates first |
| 40 | r.tmpls = template.Must(r.tmpls.ParseFS(data, "templates/*.tmpl")) |
| 41 | |
| 42 | return &r |
| 43 | } |
| 44 | |
| 45 | // LoadCustomTemplates allows to load in custom templates from a specified path. |
| 46 | func (r *Render) LoadCustomTemplates(dir string) error { |
no outgoing calls