{"record":{"id":"f12fa29c93944c23","repo":"kataras/iris","slug":"build-view-engine-v","errorCode":null,"errorMessage":"build: view engine: %v","messagePattern":"build: view engine: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"iris.go","lineNumber":743,"sourceCode":"\t\t}\n\t}\n\n\tif app.I18n.Loaded() {\n\t\t// {{ tr \"lang\" \"key\" arg1 arg2 }}\n\t\tapp.view.AddFunc(\"tr\", app.I18n.Tr)\n\t\tapp.Router.PrependRouterWrapper(app.I18n.Wrapper())\n\t}\n\n\tif app.view.Registered() {\n\t\tapp.logger.Debugf(\"Application: view engine %q is registered\", app.view.Name())\n\t\t// view engine\n\t\t// here is where we declare the closed-relative framework functions.\n\t\t// Each engine has their defaults, i.e yield,render,render_r,partial, params...\n\t\trv := router.NewRoutePathReverser(app.APIBuilder)\n\t\tapp.view.AddFunc(\"urlpath\", rv.Path)\n\t\t// app.view.AddFunc(\"url\", rv.URL)\n\t\tif err := app.view.Load(); err != nil {\n\t\t\treturn fmt.Errorf(\"build: view engine: %v\", err)\n\t\t}\n\t}\n\n\tif !app.Router.Downgraded() {\n\t\t// router\n\t\tif _, err := injectLiveReload(app); err != nil {\n\t\t\treturn fmt.Errorf(\"build: inject live reload: failed: %v\", err)\n\t\t}\n\n\t\tif app.config.ForceLowercaseRouting {\n\t\t\t// This should always be executed first.\n\t\t\tapp.Router.PrependRouterWrapper(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\t\t\t\tr.Host = strings.ToLower(r.Host)\n\t\t\t\tr.URL.Host = strings.ToLower(r.URL.Host)\n\t\t\t\tr.URL.Path = strings.ToLower(r.URL.Path)\n\t\t\t\tnext(w, r)\n\t\t\t})\n\t\t}","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/iris.go#L725-L761","documentation":"Iris wraps any error returned by the view engine's Load() during app.Build() as 'build: view engine: %v'. Load() parses and pre-compiles all registered templates; a failure means templates or view configuration are broken, so Iris aborts startup instead of serving with a broken view layer.","triggerScenarios":"Calling iris.New()/Run() with a registered view engine (e.g. app.RegisterView(iris.HTML(...))) whose template directory does not exist, contains syntax-invalid templates, references missing template names/includes, or uses an undefined template function.","commonSituations":"Wrong relative template dir path after changing working directory; template renamed or deleted but still referenced via {{ template ... }}; using a custom FuncMap name colliding with built-ins like 'urlpath'; CI/Docker images that exclude .html assets.","solutions":["Verify the template root directory path passed to the view engine is correct relative to the process working directory (use absolute paths or embed.FS).","Parse templates locally (e.g. html/template.ParseFiles) to find the exact template and line with the syntax error.","Check that all {{ template \"name\" }} references match existing defined template names and all functions used in templates are registered before Load().","If using embedded filesystems, ensure embed directives include the template files.","Read the wrapped inner error after 'build: view engine:' — it names the offending template file."],"exampleFix":"// before\napp.RegisterView(iris.HTML(\"./templates\", \".html\"))\n// after (robust to CWD / embedded assets)\nimport _ \"embed\"\napp.RegisterView(iris.HTMLFS(http.FS(templatesFS), \".\").AddFunc(\"urlpath\", nil))","handlingStrategy":"validation","validationCode":"root := \"./templates\"\nif fi, err := os.Stat(root); err != nil || !fi.IsDir() {\n    log.Fatalf(\"template dir %q missing: %v\", root, err)\n}\nif err := template.Must(template.New(\"t\").ParseGlob(filepath.Join(root, \"*.html\"))).Execute(io.Discard, nil); err != nil {\n    log.Fatalf(\"template parse check failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := app.Build(); err != nil {\n    var viewErr error\n    if strings.HasPrefix(err.Error(), \"build: view engine:\") {\n        log.Fatalf(\"view/templates misconfigured: %v\", err)\n    }\n    _ = viewErr\n    log.Fatalf(\"build failed: %v\", err)\n}","preventionTips":["Use embedded filesystems (embed.FS) for templates so builds cannot miss assets.","Parse templates in unit tests before startup.","Register all template funcs before RegisterView/Load.","Use absolute paths or paths relative to the executable, not CWD."],"tags":["go","iris","view-engine","templates","startup"],"backgroundTag":"template-load-failed","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}