LoadFiles caches (if not already) the specified filenames set as a single template and returns a ready to use Renderer instance. There must be at least 1 filename specified.
(filenames ...string)
| 83 | // |
| 84 | // There must be at least 1 filename specified. |
| 85 | func (r *Registry) LoadFiles(filenames ...string) *Renderer { |
| 86 | key := strings.Join(filenames, ",") |
| 87 | |
| 88 | found := r.cache.Get(key) |
| 89 | |
| 90 | if found == nil { |
| 91 | // parse and cache |
| 92 | tpl, err := template.New(filepath.Base(filenames[0])).Funcs(r.funcs).ParseFiles(filenames...) |
| 93 | found = &Renderer{template: tpl, parseError: err} |
| 94 | r.cache.Set(key, found) |
| 95 | } |
| 96 | |
| 97 | return found |
| 98 | } |
| 99 | |
| 100 | // LoadString caches (if not already) the specified inline string as a |
| 101 | // single template and returns a ready to use Renderer instance. |