-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Feature-Request: Make absURL and relURL accept anything #2352
Conversation
Agree. |
@@ -1803,7 +1803,7 @@ func htmlUnescape(in interface{}) (string, error) { | |||
|
|||
func init() { | |||
funcMap = template.FuncMap{ | |||
"absURL": func(a string) template.HTML { return template.HTML(helpers.AbsURL(a)) }, | |||
"absURL": func(a interface{}) template.HTML { return template.HTML(helpers.AbsURL(cast.ToString(a))) }, |
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.
Please use the ToStringE variant and return any error as second return value from the template func. Same with relURL.
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.
He learned from the best. 😉 Do the changes in 3a2a4c3 need errors returned, too?
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.
@moorereason please stick to this PR. Taking the entire commit history of Hugo into consideration for this simple change is ... Not fruitful.
We'll handle the errors as part of #2354 |
Thanks 😄 |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The template functions
relURL
andabsURL
currently only accept strings. However, after #889 many template functions likesafeHtml
were opened to accept more than strings. So I suggest that alsorelURL
andabsURL
should share this behavior. For example the following code currently throws an errorbecause
.RSSLink
is of typetemplate.HTML
(it throws an error with my versionHugo Static Site Generator v0.16-DEV BuildDate: 2016-02-06T18:14:17+01:00
shipped with Ubuntu 16.04).I followed 3a2a4c3 . Note that I never programmed in go before, so someone should check my changings :-) I am also not sure whether code injections are possible after the changes in my commit...