Skip to content

Commit

Permalink
tpl/debug: Add VisualizeSpaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Apr 20, 2023
1 parent 46a3cf6 commit f106251
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tpl/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)))
}

0 comments on commit f106251

Please sign in to comment.