mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-15 08:30:42 +08:00
🎨 Change database template column custom attribute action Fix https://github.com/siyuan-note/siyuan/issues/9401
This commit is contained in:
parent
b8e8aa0593
commit
92151f7150
@ -51,7 +51,6 @@ func renderTemplateCol(ial map[string]string, tplContent string, rowValues []*av
|
|||||||
|
|
||||||
funcMap := sprig.TxtFuncMap()
|
funcMap := sprig.TxtFuncMap()
|
||||||
goTpl := template.New("").Delims(".action{", "}")
|
goTpl := template.New("").Delims(".action{", "}")
|
||||||
tplContent = strings.ReplaceAll(tplContent, ".custom-", ".custom_") // 模板中的属性名不允许包含 - 字符,因此这里需要替换
|
|
||||||
tpl, tplErr := goTpl.Funcs(funcMap).Parse(tplContent)
|
tpl, tplErr := goTpl.Funcs(funcMap).Parse(tplContent)
|
||||||
if nil != tplErr {
|
if nil != tplErr {
|
||||||
logging.LogWarnf("parse template [%s] failed: %s", tplContent, tplErr)
|
logging.LogWarnf("parse template [%s] failed: %s", tplContent, tplErr)
|
||||||
@ -61,7 +60,7 @@ func renderTemplateCol(ial map[string]string, tplContent string, rowValues []*av
|
|||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
dataModel := map[string]interface{}{} // 复制一份 IAL 以避免修改原始数据
|
dataModel := map[string]interface{}{} // 复制一份 IAL 以避免修改原始数据
|
||||||
for k, v := range ial {
|
for k, v := range ial {
|
||||||
dataModel[strings.ReplaceAll(k, "custom-", "custom_")] = v
|
dataModel[k] = v
|
||||||
|
|
||||||
// Database template column supports `created` and `updated` built-in variables https://github.com/siyuan-note/siyuan/issues/9364
|
// Database template column supports `created` and `updated` built-in variables https://github.com/siyuan-note/siyuan/issues/9364
|
||||||
createdStr := ial["id"]
|
createdStr := ial["id"]
|
||||||
|
Loading…
Reference in New Issue
Block a user