mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
4a2c6ac5a0
commit
eee166e901
3 changed files with 31 additions and 36 deletions
|
|
@ -18,6 +18,7 @@ package sql
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
|
@ -389,6 +390,30 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, ials map[s
|
|||
}
|
||||
}
|
||||
|
||||
func fillAttributeViewTemplateValue(value *av.Value, item av.Item, attrView *av.AttributeView, ials map[string]map[string]string, items map[string][]*av.KeyValues) (err error) {
|
||||
itemID := item.GetID()
|
||||
|
||||
switch value.Type {
|
||||
case av.KeyTypeTemplate: // 渲染模板字段
|
||||
keyValues := items[itemID]
|
||||
ial := ials[itemID]
|
||||
if nil == ial {
|
||||
ial = map[string]string{}
|
||||
}
|
||||
content, renderErr := RenderTemplateField(ial, keyValues, value.Template.Content)
|
||||
value.Template.Content = content
|
||||
if nil != renderErr {
|
||||
key, _ := attrView.GetKey(value.KeyID)
|
||||
keyName := ""
|
||||
if nil != key {
|
||||
keyName = key.Name
|
||||
}
|
||||
err = fmt.Errorf("database [%s] template field [%s] rendering failed: %s", getAttrViewName(attrView), keyName, renderErr)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func fillAttributeViewNilValue(value *av.Value, typ av.KeyType) {
|
||||
value.Type = typ
|
||||
switch typ {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue