diff --git a/go.mod b/go.mod index e60d422c0..ef123e0ee 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/ChrisTrenkamp/xsel v0.9.6 github.com/SpectoLabs/goproxy v0.0.0-20220724221645-71c396c297b7 github.com/SpectoLabs/goproxy/ext v0.0.0-20220724221645-71c396c297b7 - github.com/SpectoLabs/raymond v2.0.2+incompatible + github.com/SpectoLabs/raymond v2.0.3-0.20240313203747-f578a6519e58+incompatible github.com/antonholmquist/jason v1.0.1-0.20160829104012-962e09b85496 github.com/beevik/etree v1.1.0 github.com/boltdb/bolt v1.2.1-0.20160424201119-d97499360d1e diff --git a/go.sum b/go.sum index 420a9ff7a..d5f6c29c2 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/SpectoLabs/goproxy v0.0.0-20220724221645-71c396c297b7 h1:TTZvVLRa0sjo github.com/SpectoLabs/goproxy v0.0.0-20220724221645-71c396c297b7/go.mod h1:tj8G0iNIS9fkG5PSrzQYLUXcvhtqI8XbIld9PqpYaFw= github.com/SpectoLabs/goproxy/ext v0.0.0-20220724221645-71c396c297b7 h1:MxMvFwL66nKnrmjHhp9GODbHVZ+/qS2MmvnXz/nDdR4= github.com/SpectoLabs/goproxy/ext v0.0.0-20220724221645-71c396c297b7/go.mod h1:rnDN1CpKP9iJXwxRtnvM7d5wdPHQY0K5NkHeXWPlQ+o= -github.com/SpectoLabs/raymond v2.0.2+incompatible h1:75q2/r2f6U38xSTDHUbJWZnkVY9dKUeQi8M9HMa1icc= -github.com/SpectoLabs/raymond v2.0.2+incompatible/go.mod h1:Cv+3TFLm3T7C7ML7gEK4HnHcTpfc4HjJFWvS91cc6tw= +github.com/SpectoLabs/raymond v2.0.3-0.20240313203747-f578a6519e58+incompatible h1:Oa+gbcUjsRQAiFZHmTesK1Py0FWBmHUNoXtBUz9oqvk= +github.com/SpectoLabs/raymond v2.0.3-0.20240313203747-f578a6519e58+incompatible/go.mod h1:Cv+3TFLm3T7C7ML7gEK4HnHcTpfc4HjJFWvS91cc6tw= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/antonholmquist/jason v1.0.1-0.20160829104012-962e09b85496 h1:dESITdufxuiwgQh1YPiPupEXORHTYvY8tr40nvrWelo= github.com/antonholmquist/jason v1.0.1-0.20160829104012-962e09b85496/go.mod h1:+GxMEKI0Va2U8h3os6oiUAetHAlGMvxjdpAH/9uvUMA= diff --git a/vendor/github.com/SpectoLabs/raymond/.gitignore b/vendor/github.com/SpectoLabs/raymond/.gitignore new file mode 100644 index 000000000..85e7c1dfc --- /dev/null +++ b/vendor/github.com/SpectoLabs/raymond/.gitignore @@ -0,0 +1 @@ +/.idea/ diff --git a/vendor/github.com/SpectoLabs/raymond/CHANGELOG.md b/vendor/github.com/SpectoLabs/raymond/CHANGELOG.md index 0efaf1804..ca4e14e9f 100644 --- a/vendor/github.com/SpectoLabs/raymond/CHANGELOG.md +++ b/vendor/github.com/SpectoLabs/raymond/CHANGELOG.md @@ -1,5 +1,9 @@ # Raymond Changelog +### HEAD + +- [IMPROVEMENT] Add `RemoveHelper` and `RemoveAllHelpers` functions + ### Raymond 2.0.2 _(March 22, 2018)_ - [IMPROVEMENT] Add the #equal helper (#7) diff --git a/vendor/github.com/SpectoLabs/raymond/README.md b/vendor/github.com/SpectoLabs/raymond/README.md index d9a6d9a2c..d1e2b8fdf 100644 --- a/vendor/github.com/SpectoLabs/raymond/README.md +++ b/vendor/github.com/SpectoLabs/raymond/README.md @@ -422,11 +422,21 @@ ctx := Post{ }, } -RegisterHelper("fullName", func(person Person) string { +raymond.RegisterHelper("fullName", func(person Person) string { return person.FirstName + " " + person.LastName }) ``` +You can unregister global helpers with `RemoveHelper` and `RemoveAllHelpers` functions: + +```go +raymond.RemoveHelper("fullname") +``` + +```go +raymond.RemoveAllHelpers() +``` + ### Template Helpers diff --git a/vendor/github.com/SpectoLabs/raymond/eval.go b/vendor/github.com/SpectoLabs/raymond/eval.go index 7683f4e4f..e689c31a9 100644 --- a/vendor/github.com/SpectoLabs/raymond/eval.go +++ b/vendor/github.com/SpectoLabs/raymond/eval.go @@ -822,7 +822,7 @@ func (v *evalVisitor) VisitBlock(node *ast.BlockStatement) interface{} { expr := node.Expression.Accept(v) if v.isHelperCall(node.Expression) || v.wasFuncCall(node.Expression) { - // it is the responsability of the helper/function to evaluate block + // it is the responsibility of the helper/function to evaluate block result = expr } else { val := reflect.ValueOf(expr) diff --git a/vendor/github.com/SpectoLabs/raymond/helper.go b/vendor/github.com/SpectoLabs/raymond/helper.go index 15c830944..dda3e95fd 100644 --- a/vendor/github.com/SpectoLabs/raymond/helper.go +++ b/vendor/github.com/SpectoLabs/raymond/helper.go @@ -56,6 +56,22 @@ func RegisterHelpers(helpers map[string]interface{}) { } } +// RemoveHelper unregisters a global helper +func RemoveHelper(name string) { + helpersMutex.Lock() + defer helpersMutex.Unlock() + + delete(helpers, name) +} + +// RemoveAllHelpers unregisters all global helpers +func RemoveAllHelpers() { + helpersMutex.Lock() + defer helpersMutex.Unlock() + + helpers = make(map[string]reflect.Value) +} + // ensureValidHelper panics if given helper is not valid func ensureValidHelper(name string, funcValue reflect.Value) { if funcValue.Kind() != reflect.Func { @@ -100,6 +116,19 @@ func newEmptyOptions(eval *evalVisitor) *Options { // Context Values // +// ValueFromAllCtx returns the first occurence of field value from all the contexts in the stack. The search occurs backwards from the current context, ending at the root context. +func (options *Options) ValueFromAllCtx(name string) interface{} { + // Loop through all contexts in the stack + for index := range options.eval.ctx { + value := options.eval.evalField(options.eval.ancestorCtx(index), name, false) + if value.IsValid() { + return value.Interface() + } + } + + return nil +} + // Value returns field value from current context. func (options *Options) Value(name string) interface{} { value := options.eval.evalField(options.eval.curCtx(), name, false) diff --git a/vendor/github.com/SpectoLabs/raymond/partial.go b/vendor/github.com/SpectoLabs/raymond/partial.go index 3299d02ce..d9591139d 100644 --- a/vendor/github.com/SpectoLabs/raymond/partial.go +++ b/vendor/github.com/SpectoLabs/raymond/partial.go @@ -62,6 +62,22 @@ func RegisterPartialTemplate(name string, tpl *Template) { partials[name] = newPartial(name, "", tpl) } +// RemovePartial removes the partial registered under the given name. The partial will not be available globally anymore. This does not affect partials registered on a specific template. +func RemovePartial(name string) { + partialsMutex.Lock() + defer partialsMutex.Unlock() + + delete(partials, name) +} + +// RemoveAllPartials removes all globally registered partials. This does not affect partials registered on a specific template. +func RemoveAllPartials() { + partialsMutex.Lock() + defer partialsMutex.Unlock() + + partials = make(map[string]*partial) +} + // findPartial finds a registered global partial func findPartial(name string) *partial { partialsMutex.RLock() diff --git a/vendor/modules.txt b/vendor/modules.txt index 9f7224d6b..223057fb4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -21,7 +21,7 @@ github.com/SpectoLabs/goproxy # github.com/SpectoLabs/goproxy/ext v0.0.0-20220724221645-71c396c297b7 ## explicit github.com/SpectoLabs/goproxy/ext/auth -# github.com/SpectoLabs/raymond v2.0.2+incompatible +# github.com/SpectoLabs/raymond v2.0.3-0.20240313203747-f578a6519e58+incompatible ## explicit github.com/SpectoLabs/raymond # github.com/antonholmquist/jason v1.0.1-0.20160829104012-962e09b85496