Skip to content

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

:art: Improve av https://github.com/siyuan-note/siyuan/issues/15527

Daniel93fdc69becfa
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 8de8bd6957..139bfc51d3 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -1493,12 +1493,14 @@ func GetBlockAttributeViewKeys(nodeID string) (ret []*BlockAttributeViewKeys) {
switch kv.Key.Type {
case av.KeyTypeTemplate:
if 0 < len(kv.Values) {
- ial := map[string]string{}
+ var ial map[string]string
block := av.GetKeyBlockValue(keyValues)
if nil != block && !block.IsDetached {
ial = sql.GetBlockAttrs(block.BlockID)
}
-
+ if nil == ial {
+ ial = map[string]string{}
+ }
if nil == kv.Values[0].Template {
kv.Values[0] = av.GetAttributeViewDefaultValue(kv.Values[0].ID, kv.Key.ID, nodeID, kv.Key.Type)
}
diff --git a/kernel/sql/av.go b/kernel/sql/av.go
index 6a383e4d4e..26af3224bd 100644
--- a/kernel/sql/av.go
+++ b/kernel/sql/av.go
@@ -488,11 +488,14 @@ func fillAttributeViewTemplateValues(attrView *av.AttributeView, collection av.C
switch value.Type {
case av.KeyTypeTemplate: // 渲染模板字段
keyValues := items[itemID]
- ial := map[string]string{}
+ var ial map[string]string
blockVal := item.GetBlockValue()
if nil != blockVal {
ial = ials[blockVal.Block.ID]
}
+ if nil == ial {
+ ial = map[string]string{}
+ }
content, renderErr := RenderTemplateField(ial, keyValues, value.Template.Content)
value.Template.Content = content
if nil != renderErr {