Sprig模板全局变量示例
see https://ld246.com/article/1733921523331
markdown
.action{ $total := 0 }
.action{$id := .id}
.action{ $blocks := queryBlocks "select * from blocks where root_id = '?' and id != '?'" $id $id }
.action{ range $v := $blocks }
.action{ $len := len $v.Content }
.action{ $total = add $total $len }
.action{ end }
.action{ $total }
注意,全局变量要用 .action{ $total = } 而不能用 .action{ $total := }