🎨 Add block content statistics template function statBlock https://github.com/siyuan-note/siyuan/issues/13438

This commit is contained in:
Daniel 2024-12-11 23:59:58 +08:00
parent e2017a9fba
commit 11d3516aa7
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 237 additions and 167 deletions

View file

@ -34,6 +34,7 @@ import (
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/av"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode"
@ -43,7 +44,7 @@ import (
func RenderGoTemplate(templateContent string) (ret string, err error) {
tmpl := template.New("")
tplFuncMap := treenode.BuiltInTemplateFuncs()
tplFuncMap := filesys.BuiltInTemplateFuncs()
sql.SQLTemplateFuncs(&tplFuncMap)
tmpl = tmpl.Funcs(tplFuncMap)
tpl, err := tmpl.Parse(templateContent)
@ -254,7 +255,7 @@ func RenderDynamicIconContentTemplate(content, id string) (ret string) {
dataModel["alias"] = block.Alias
goTpl := template.New("").Delims(".action{", "}")
tplFuncMap := treenode.BuiltInTemplateFuncs()
tplFuncMap := filesys.BuiltInTemplateFuncs()
sql.SQLTemplateFuncs(&tplFuncMap)
goTpl = goTpl.Funcs(tplFuncMap)
tpl, err := goTpl.Funcs(tplFuncMap).Parse(content)
@ -304,7 +305,7 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, e
}
goTpl := template.New("").Delims(".action{", "}")
tplFuncMap := treenode.BuiltInTemplateFuncs()
tplFuncMap := filesys.BuiltInTemplateFuncs()
sql.SQLTemplateFuncs(&tplFuncMap)
goTpl = goTpl.Funcs(tplFuncMap)
tpl, err := goTpl.Funcs(tplFuncMap).Parse(gulu.Str.FromBytes(md))