mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Add template function getBlock https://github.com/siyuan-note/siyuan/issues/14474
This commit is contained in:
parent
566c90cbba
commit
536aa39f95
5 changed files with 301 additions and 150 deletions
|
|
@ -1518,6 +1518,17 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) {
|
|||
retBlocks = SelectBlocksRawStmt(stmt, 1, 512)
|
||||
return
|
||||
}
|
||||
(*templateFuncMap)["getBlock"] = func(arg any) (retBlock *Block) {
|
||||
switch v := arg.(type) {
|
||||
case string:
|
||||
retBlock = GetBlock(v)
|
||||
case map[string]interface{}:
|
||||
if id, ok := v["id"]; ok {
|
||||
retBlock = GetBlock(id.(string))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
(*templateFuncMap)["querySpans"] = func(stmt string, args ...string) (retSpans []*Span) {
|
||||
for _, arg := range args {
|
||||
stmt = strings.Replace(stmt, "?", arg, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue