Skip to content

Commit

Permalink
🎨 Add template type column to Attribute View siyuan-note#8766
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 1, 2023
1 parent bfd27a6 commit b4bded4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
funcMap := sprig.TxtFuncMap()
goTpl := template.New("").Delims(".action{", "}")
tplContent := col.Template
tplContent = strings.ReplaceAll(tplContent, ".custom-", ".custom_")
tplContent = strings.ReplaceAll(tplContent, ".custom-", ".custom_") // 模板中的属性名不允许包含 - 字符,因此这里需要替换
tpl, tplErr := goTpl.Funcs(funcMap).Parse(tplContent)
if nil != tplErr {
logging.LogWarnf("parse template [%s] failed: %s", tplContent, tplErr)
Expand All @@ -246,7 +246,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a

buf := &bytes.Buffer{}
ial := GetBlockAttrs(blockID)
dataModel := map[string]string{}
dataModel := map[string]string{} // 复制一份 IAL 以避免修改原始数据
for k, v := range ial {
dataModel[strings.ReplaceAll(k, "custom-", "custom_")] = v
}
Expand Down

0 comments on commit b4bded4

Please sign in to comment.