siyuan-note/siyuan · error
Conf.Language(44) {err.Error()}
Error message
Conf.Language(44) {err.Error()} What it means
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.
Source
Thrown at kernel/model/template.go:75
// RenderGoTemplateAt 使用固定时间渲染 Go 模板,保证同一次业务操作中的多个模板结果一致。
func RenderGoTemplateAt(templateContent string, now time.Time) (ret string, err error) {
return RenderGoTemplateAtInBox(templateContent, now, "")
}
func RenderGoTemplateInBox(templateContent, boxID string) (ret string, err error) {
return RenderGoTemplateAtInBox(templateContent, time.Now(), boxID)
}
func RenderGoTemplateAtInBox(templateContent string, now time.Time, boxID string) (ret string, err error) {
tmpl := template.New("")
tplFuncMap := filesys.BuiltInTemplateFuncs()
tplFuncMap["now"] = func() time.Time { return now }
sql.SQLTemplateFuncs(&tplFuncMap, boxID)
tmpl = tmpl.Funcs(tplFuncMap)
tpl, err := tmpl.Parse(templateContent)
if err != nil {
return "", fmt.Errorf(Conf.Language(44), err.Error())
}
buf := &bytes.Buffer{}
buf.Grow(4096)
err = tpl.Execute(buf, nil)
if err != nil {
return "", fmt.Errorf(Conf.Language(44), err.Error())
}
ret = buf.String()
return
}
// RemoveTemplate 删除模板文件,路径必须限定在 <data>/templates/ 目录内,防止任意文件被删除
func RemoveTemplate(p string) (err error) {
abs := p
if !filepath.IsAbs(abs) {
abs = filepath.Join(util.DataDir, "templates", p)
}View on GitHub (pinned to 251596fc0d)
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.
Example fix
// before — mismatched delimiters cause parse failure
{{if .title}<h1>{{.title}}</h1>{{end}
// after — balanced delimiters
{{if .title}}<h1>{{.title}}</h1>{{end}} Defensive patterns
Strategy: validation
Validate before calling
// Validate Go template parses before calling RenderGoTemplateInBox
import "text/template"
func preflightGoTemplate(content string, funcs template.FuncMap) error {
_, err := template.New("").Funcs(funcs).Parse(content)
return err
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Parse template failed: %s
- parse tree [%s] failed
- parse template [%s] failed: %s
- execute template [%s] failed: %s
- appearance files not found at [%s]
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/95d2b39285c7152b.
Report an issue: GitHub.