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

Merged
merged 1 commit into from Aug 12, 2016

Conversation

Projects
None yet
4 participants
@kulla
Contributor

kulla commented Aug 12, 2016

The template functions relURL and absURL currently only accept strings. However, after #889 many template functions like safeHtml were opened to accept more than strings. So I suggest that also relURL and absURL should share this behavior. For example the following code currently throws an error

{{ .RSSLink | relURL }}

because .RSSLink is of type template.HTML (it throws an error with my version Hugo 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...

@CLAassistant

This comment has been minimized.

Show comment
Hide comment
@CLAassistant

CLAassistant Aug 12, 2016

CLA assistant check
All committers have signed the CLA.

CLAassistant commented Aug 12, 2016

CLA assistant check
All committers have signed the CLA.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Aug 12, 2016

Member

Agree.

Member

bep commented Aug 12, 2016

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))) },

This comment has been minimized.

@bep

bep Aug 12, 2016

Member

Please use the ToStringE variant and return any error as second return value from the template func. Same with relURL.

@bep

bep Aug 12, 2016

Member

Please use the ToStringE variant and return any error as second return value from the template func. Same with relURL.

This comment has been minimized.

@moorereason

moorereason Aug 12, 2016

Contributor

He learned from the best. 😉 Do the changes in 3a2a4c3 need errors returned, too?

@moorereason

moorereason Aug 12, 2016

Contributor

He learned from the best. 😉 Do the changes in 3a2a4c3 need errors returned, too?

This comment has been minimized.

@bep

bep Aug 12, 2016

Member

@moorereason please stick to this PR. Taking the entire commit history of Hugo into consideration for this simple change is ... Not fruitful.

@bep

bep Aug 12, 2016

Member

@moorereason please stick to this PR. Taking the entire commit history of Hugo into consideration for this simple change is ... Not fruitful.

@bep bep merged commit 88dcbc6 into gohugoio:master Aug 12, 2016

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/wercker Wercker build passed
Details
licence/cla Contributor License Agreement is signed.
Details
@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Aug 12, 2016

Member

We'll handle the errors as part of #2354

Member

bep commented Aug 12, 2016

We'll handle the errors as part of #2354

@kulla

This comment has been minimized.

Show comment
Hide comment
@kulla

kulla Aug 13, 2016

Contributor

Thanks 😄

Contributor

kulla commented Aug 13, 2016

Thanks 😄

@kulla kulla deleted the kulla:relurl-and-absurl-accept-anything branch Aug 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment