Open returns a template's contents, or an error if no template was added under this path using Set().
(templatePath string)
| 108 | |
| 109 | // Open returns a template's contents, or an error if no template was added under this path using Set(). |
| 110 | func (l *InMemLoader) Open(templatePath string) (io.ReadCloser, error) { |
| 111 | templatePath = l.normalize(templatePath) |
| 112 | l.lock.RLock() |
| 113 | defer l.lock.RUnlock() |
| 114 | f, ok := l.files[templatePath] |
| 115 | if !ok { |
| 116 | return nil, fmt.Errorf("%s does not exist", templatePath) |
| 117 | } |
| 118 | |
| 119 | return io.NopCloser(bytes.NewReader(f)), nil |
| 120 | } |
| 121 | |
| 122 | // Exists returns whether or not a template is indexed under this path. |
| 123 | func (l *InMemLoader) Exists(templatePath string) bool { |