{"record":{"id":"755f3fbb7f86e02a","repo":"kataras/iris","slug":"no-templates-found","errorCode":null,"errorMessage":"no templates found","messagePattern":"no templates found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"view/html.go","lineNumber":299,"sourceCode":"\n\t\tbuf, err := asset(s.fs, path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", path, err)\n\t\t}\n\n\t\treturn s.parseTemplate(path, buf, nil)\n\t})\n\n\tif s.onLoaded != nil {\n\t\ts.onLoaded()\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif s.Templates == nil {\n\t\treturn fmt.Errorf(\"no templates found\")\n\t}\n\n\treturn nil\n}\n\nfunc (s *HTMLEngine) reloadCustomTemplates() error {\n\tfor _, tmpl := range s.customCache {\n\t\tif err := s.parseTemplate(tmpl.name, tmpl.contents, tmpl.funcs); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// ParseTemplate adds a custom template to the root template.\nfunc (s *HTMLEngine) ParseTemplate(name string, contents []byte, funcs template.FuncMap) (err error) {\n\ts.rmu.Lock()","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/view/html.go#L281-L317","documentation":"HTMLEngine.Load finishes walking the configured filesystem and, if s.Templates is still nil, no template files were found/parsed at all. The library raises this so an empty or misconfigured template root fails loudly at load time rather than returning 'template not found' on every request.","triggerScenarios":"Calling Load (directly or via View.Load / first ExecuteWriter) when the engine's loader found zero files — empty fs root, wrong directory, wrong file extension, or no templates embedded.","commonSituations":"go:embed pattern matches nothing (e.g. embed of an empty dir); extension mismatch (engine registered with \".html\" but files are \".tmpl\"); running the binary from a directory where the templates folder doesn't exist in os filesystem mode.","solutions":["Fix the go:embed directive or the engine's root directory so it actually contains template files with the registered extension.","Verify files use the extension passed to html.New (e.g. \".html\"); rename or reconfigure.","Call Load() at startup and check the error so a broken deployment is caught immediately."],"exampleFix":"// before\n//go:embed views\nvar fs embed.FS\nengine := html.New(fs, \".html\") // views contains .gohtml files only\n// after\nengine := html.New(fs, \".gohtml\")","handlingStrategy":"validation","validationCode":"matched, _ := fs.Glob(tmplFS, \"templates/*.html\")\nif len(matched) == 0 {\n    log.Fatal(\"no *.html templates found under templates/ — check embed directive and extension\")\n}","typeGuard":null,"tryCatchPattern":"if err := engine.Load(); err != nil {\n    if strings.Contains(err.Error(), \"no templates found\") {\n        log.Fatalf(\"template root misconfigured: %v\", err)\n    }\n    return err\n}","preventionTips":["Verify the go:embed pattern actually matches files (empty dirs are not embedded by default).","Match the engine's extension argument to the real file extensions on disk.","Assert template count > 0 in an integration test that runs the loader.","Use embed.All or an explicit directory embed instead of a possibly-empty glob."],"tags":["template-loading","empty-directory","view-engine","configuration"],"backgroundTag":"no-templates-found","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}