{"record":{"id":"95d2b39285c7152b","repo":"siyuan-note/siyuan","slug":"conf-language-44-err-error","errorCode":null,"errorMessage":"Conf.Language(44) {err.Error()}","messagePattern":"Conf\\.Language\\(44\\) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":75,"sourceCode":"\n// RenderGoTemplateAt 使用固定时间渲染 Go 模板，保证同一次业务操作中的多个模板结果一致。\nfunc RenderGoTemplateAt(templateContent string, now time.Time) (ret string, err error) {\n\treturn RenderGoTemplateAtInBox(templateContent, now, \"\")\n}\n\nfunc RenderGoTemplateInBox(templateContent, boxID string) (ret string, err error) {\n\treturn RenderGoTemplateAtInBox(templateContent, time.Now(), boxID)\n}\n\nfunc RenderGoTemplateAtInBox(templateContent string, now time.Time, boxID string) (ret string, err error) {\n\ttmpl := template.New(\"\")\n\ttplFuncMap := filesys.BuiltInTemplateFuncs()\n\ttplFuncMap[\"now\"] = func() time.Time { return now }\n\tsql.SQLTemplateFuncs(&tplFuncMap, boxID)\n\ttmpl = tmpl.Funcs(tplFuncMap)\n\ttpl, err := tmpl.Parse(templateContent)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(Conf.Language(44), err.Error())\n\t}\n\n\tbuf := &bytes.Buffer{}\n\tbuf.Grow(4096)\n\terr = tpl.Execute(buf, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(Conf.Language(44), err.Error())\n\t}\n\tret = buf.String()\n\treturn\n}\n\n// RemoveTemplate 删除模板文件，路径必须限定在 <data>/templates/ 目录内，防止任意文件被删除\nfunc RemoveTemplate(p string) (err error) {\n\tabs := p\n\tif !filepath.IsAbs(abs) {\n\t\tabs = filepath.Join(util.DataDir, \"templates\", p)\n\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/template.go#L57-L93","documentation":"Returned by RenderGoTemplateAtInBox when Go's text/template fails to PARSE the template string (template.go:75). The message is the localized string Conf.Language(44) = \"Parse template failed: %s\" with the underlying parse error interpolated. This is a syntax/grammar error in the template body, surfaced before any execution begins.","triggerScenarios":"Calling RenderGoTemplateInBox or RenderGoTemplateAtInBox with a templateContent containing malformed Go template syntax: unbalanced delimiters {{ }}, unclosed actions, undefined pipeline operators, stray braces, or invalid function names recognized only at parse time. This function is the entry point for rendering notebook-level Go templates (e.g. templates invoked from doc/spaced-repetition/breadcrumb contexts that use {{now}} and SQL template funcs).","commonSituations":"A user-authored template in <data>/templates/ uses {{ } Go template delimiters incorrectly; mixing Lute/Kramdown template syntax (.action{}) with Go template syntax ({{}}) in a file passed to the Go-template renderer; copying a dynamic-icon template (which uses .action{} delimiters) into a path consumed by RenderGoTemplateInBox which expects {{}} delimiters.","solutions":["Open the offending template file and validate it with Go's text/template locally: tmpl, err := template.New(\"\").Parse(content); fix any reported line/column.","Ensure you use {{ }} delimiters here — this renderer does NOT set custom delimiters (unlike RenderTemplate which uses .action{}), so .action{...} syntax will be treated as literal text or fail.","Confirm all functions referenced in the template are in the built-in template func map (filesys.BuiltInTemplateFuncs) or the SQL template funcs; an unknown function is a parse error.","Remove stray single braces { or } that are not part of a valid action; escape literal braces as {{\"{{\"}} if you need literal braces."],"exampleFix":"// before — mismatched delimiters cause parse failure\n{{if .title}<h1>{{.title}}</h1>{{end}\n\n// after — balanced delimiters\n{{if .title}}<h1>{{.title}}</h1>{{end}}","handlingStrategy":"validation","validationCode":"// Validate Go template parses before calling RenderGoTemplateInBox\nimport \"text/template\"\n\nfunc preflightGoTemplate(content string, funcs template.FuncMap) error {\n    _, err := template.New(\"\").Funcs(funcs).Parse(content)\n    return err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember RenderGoTemplateInBox uses default {{ }} delimiters — do NOT mix .action{} syntax into files passed to it.","Lint template files in CI with a Go text/template parse step before shipping.","Keep notebook-level Go templates and content (.action{}) templates in clearly named files to avoid passing one to the wrong renderer."],"tags":["template","go-template","i18n","parsing"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}