diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-04-20 11:27:55 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-04-20 11:27:55 +0200 |
commit | f1062519ae7d5dd41b681e43e992dbc66fcd0855 (patch) | |
tree | 646179e86c0262b0c1045e8bde08a3f5f3c69898 /tpl | |
parent | 46a3cf61862a5034664f32fa2674a649aeda51b9 (diff) |
tpl/debug: Add VisualizeSpaces
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/debug/debug.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tpl/debug/debug.go b/tpl/debug/debug.go index 11c925c75..d07a2804e 100644 --- a/tpl/debug/debug.go +++ b/tpl/debug/debug.go @@ -16,6 +16,8 @@ package debug import ( "github.com/sanity-io/litter" + "github.com/spf13/cast" + "github.com/yuin/goldmark/util" "github.com/gohugoio/hugo/deps" ) @@ -41,3 +43,9 @@ type Namespace struct { func (ns *Namespace) Dump(val any) string { return litter.Sdump(val) } + +// VisualizeSpaces returns a string with spaces replaced by a visible string. +func (ns *Namespace) VisualizeSpaces(val any) string { + s := cast.ToString(val) + return string(util.VisualizeSpaces([]byte(s))) +} |