Skip to content

Commit

Permalink
🎨 Database template col type
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 5, 2023
1 parent 0df2bd7 commit 8db022e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ func renderTemplateCol(blockID, tplContent string, rowValues []*av.KeyValues) st

buf := &bytes.Buffer{}
ial := GetBlockAttrs(blockID)
dataModel := map[string]string{} // 复制一份 IAL 以避免修改原始数据
dataModel := map[string]interface{}{} // 复制一份 IAL 以避免修改原始数据
for k, v := range ial {
dataModel[strings.ReplaceAll(k, "custom-", "custom_")] = v
}
for _, rowValue := range rowValues {
if 0 < len(rowValue.Values) {
dataModel[rowValue.Key.Name] = rowValue.Values[0].String()
v := rowValue.Values[0]
if av.KeyTypeNumber == v.Type {
dataModel[rowValue.Key.Name] = v.Number.Content
} else {
dataModel[rowValue.Key.Name] = v.String()
}
}
}
if err := tpl.Execute(buf, dataModel); nil != err {
Expand Down

0 comments on commit 8db022e

Please sign in to comment.