MCPcopy Create free account
hub / github.com/kataras/iris / load

Method load

view/html.go:246–303  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

244}
245
246func (s *HTMLEngine) load() error {
247 if s.onLoad != nil {
248 s.onLoad()
249 }
250
251 if err := s.reloadCustomTemplates(); err != nil {
252 return err
253 }
254
255 // If only custom templates should be loaded.
256 if (s.fs == nil || context.IsNoOpFS(s.fs)) && len(s.Templates.DefinedTemplates()) > 0 {
257 return nil
258 }
259
260 rootDirName := getRootDirName(s.fs)
261
262 err := walk(s.fs, "", func(path string, info os.FileInfo, err error) error {
263 if err != nil {
264 return err
265 }
266
267 if info == nil || info.IsDir() {
268 return nil
269 }
270
271 if s.extension != "" {
272 if !strings.HasSuffix(path, s.extension) {
273 return nil
274 }
275 }
276
277 if s.rootDir == rootDirName {
278 path = strings.TrimPrefix(path, rootDirName)
279 path = strings.TrimPrefix(path, "/")
280 }
281
282 buf, err := asset(s.fs, path)
283 if err != nil {
284 return fmt.Errorf("%s: %w", path, err)
285 }
286
287 return s.parseTemplate(path, buf, nil)
288 })
289
290 if s.onLoaded != nil {
291 s.onLoaded()
292 }
293
294 if err != nil {
295 return err
296 }
297
298 if s.Templates == nil {
299 return fmt.Errorf("no templates found")
300 }
301
302 return nil
303}

Callers 2

LoadMethod · 0.95
ExecuteWriterMethod · 0.95

Calls 8

reloadCustomTemplatesMethod · 0.95
parseTemplateMethod · 0.95
IsNoOpFSFunction · 0.92
getRootDirNameFunction · 0.85
walkFunction · 0.85
ErrorfMethod · 0.80
assetFunction · 0.70
IsDirMethod · 0.45

Tested by

no test coverage detected