Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Add template type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8766

Danielbfd27a62d1ec
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index c68d1d5520..3846ebe8de 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -236,16 +236,22 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
render := func(blockID string) string {
funcMap := sprig.TxtFuncMap()
goTpl := template.New("").Delims(".action{", "}")
- tpl, tplErr := goTpl.Funcs(funcMap).Parse(col.Template)
+ tplContent := col.Template
+ tplContent = strings.ReplaceAll(tplContent, ".custom-", ".custom_")
+ tpl, tplErr := goTpl.Funcs(funcMap).Parse(tplContent)
if nil != tplErr {
- logging.LogWarnf("parse template [%s] failed: %s", col.Template, tplErr)
+ logging.LogWarnf("parse template [%s] failed: %s", tplContent, tplErr)
return ""
}
buf := &bytes.Buffer{}
ial := GetBlockAttrs(blockID)
- if err = tpl.Execute(buf, ial); nil != err {
- logging.LogWarnf("execute template [%s] failed: %s", col.Template, err)
+ dataModel := map[string]string{}
+ for k, v := range ial {
+ dataModel[strings.ReplaceAll(k, "custom-", "custom_")] = v
+ }
+ if err = tpl.Execute(buf, dataModel); nil != err {
+ logging.LogWarnf("execute template [%s] failed: %s", tplContent, err)
}
return buf.String()
}