Load should load the templates from a physical system directory or by an embedded one (assets/go-bindata).
()
| 228 | |
| 229 | // Load should load the templates from a physical system directory or by an embedded one (assets/go-bindata). |
| 230 | func (s *JetEngine) Load() error { |
| 231 | rootDirName := getRootDirName(s.fs) |
| 232 | |
| 233 | return walk(s.fs, "", func(path string, info os.FileInfo, err error) error { |
| 234 | if err != nil { |
| 235 | return err |
| 236 | } |
| 237 | |
| 238 | if info == nil || info.IsDir() { |
| 239 | return nil |
| 240 | } |
| 241 | |
| 242 | if s.extension != "" { |
| 243 | if !strings.HasSuffix(path, s.extension) { |
| 244 | return nil |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | if s.rootDir == rootDirName { |
| 249 | path = strings.TrimPrefix(path, rootDirName) |
| 250 | path = strings.TrimPrefix(path, "/") |
| 251 | } |
| 252 | |
| 253 | buf, err := asset(s.fs, path) |
| 254 | if err != nil { |
| 255 | return fmt.Errorf("%s: %w", path, err) |
| 256 | } |
| 257 | |
| 258 | return s.ParseTemplate(path, string(buf)) |
| 259 | }) |
| 260 | } |
| 261 | |
| 262 | // ParseTemplate accepts a name and contnets to parse and cache a template. |
| 263 | // This parser does not support funcs per template. Use the `AddFunc` instead. |
nothing calls this directly
no test coverage detected