mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
committed by
Bjørn Erik Pedersen
parent
983b8d537c
commit
6624979e1b
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
"github.com/rogpeppe/go-internal/diff"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
@@ -172,6 +173,15 @@ func (ns *Namespace) ContainsNonSpace(s any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Diff returns an anchored diff of the two texts old and new in the “unified
|
||||
// diff” format. If old and new are identical, Diff returns an empty string.
|
||||
func (ns *Namespace) Diff(oldname string, old any, newname string, new any) string {
|
||||
oldb := []byte(cast.ToString(old))
|
||||
newb := []byte(cast.ToString(new))
|
||||
|
||||
return string(diff.Diff(oldname, oldb, newname, newb))
|
||||
}
|
||||
|
||||
// HasPrefix tests whether the input s begins with prefix.
|
||||
func (ns *Namespace) HasPrefix(s, prefix any) (bool, error) {
|
||||
ss, err := cast.ToStringE(s)
|
||||
|
Reference in New Issue
Block a user