-
Notifications
You must be signed in to change notification settings - Fork 216
Templating functions - setHeader, initArray, variadic concat #1201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
core/templating/templating.go
Outdated
//helperMethodMap["concat"] = t.concat | ||
|
||
// Register concatMany to accept a slice of interface{} | ||
raymond.RemoveHelper("concat") | ||
raymond.RegisterHelper("concat", func(args ...interface{}) string { | ||
var parts []string | ||
for _, arg := range args { | ||
// If arg is a slice, flatten it | ||
if s, ok := arg.([]interface{}); ok { | ||
for _, v := range s { | ||
parts = append(parts, fmt.Sprint(v)) | ||
} | ||
} else { | ||
parts = append(parts, fmt.Sprint(arg)) | ||
} | ||
} | ||
return strings.Join(parts, "") | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this? you have already defined a concat
function: bbd9d32#diff-794c9f946ba3753b6d7e501b54401cd2a6029c65ea921f46104e3b3b29c6102fR120
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the duplication - the manually registered helper now calls the function in template_helpers
} else { | ||
// @todo Maybe we can panic on that | ||
return reflect.Zero(strType) | ||
if funcType.IsVariadic() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have we manually updated this file in vendor package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in order to support variadic template helpers
No description provided.