mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
📝 Add a template function runeLen https://github.com/siyuan-note/siyuan/issues/13438
This commit is contained in:
parent
2f39c2f1bc
commit
29b5124591
5 changed files with 176 additions and 22 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"math"
|
||||
"text/template"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/88250/go-humanize"
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
|
|
@ -50,9 +51,14 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {
|
|||
ret["FormatFloat"] = FormatFloat
|
||||
ret["getHPathByID"] = getHPathByID
|
||||
ret["statBlock"] = StatBlock
|
||||
ret["runeLen"] = runeLen
|
||||
return
|
||||
}
|
||||
|
||||
func runeLen(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
|
||||
func pow(a, b interface{}) int64 { return int64(math.Pow(cast.ToFloat64(a), cast.ToFloat64(b))) }
|
||||
func powf(a, b interface{}) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) }
|
||||
func log(a, b interface{}) int64 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue