Skip to content
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

relLangURL doc doesn't specify the return type #2000

Closed
willfaught opened this issue Mar 16, 2023 · 4 comments · Fixed by #2253
Closed

relLangURL doc doesn't specify the return type #2000

willfaught opened this issue Mar 16, 2023 · 4 comments · Fixed by #2253

Comments

@willfaught
Copy link
Contributor

It's implied it's a string, or at worst a url.URL:

Returns a relative URL with a language prefix, if any.

However, it appears to be template.HTML. Is that correct?

@bep
Copy link
Member

bep commented Mar 16, 2023

However, it appears to be template.HTML. Is that correct?

That is correct (and template.HTML is a string)

I'm (in this moment) working on a new and complete (auto generated) reference section for the Hugo Docs where all functions, methods and types should be documented.

@willfaught
Copy link
Contributor Author

It's surprising that a "URL" is represented by something called template.HTML, even if it's just a string under the hood.

This breaks calling .GetPage with the output of relLangURL. Perhaps relLangURL could be made to convert template.HTML to string, rather than we having to call string explicitly?

@jmooring
Copy link
Member

@willfaught

Perhaps relLangURL could be made to convert template.HTML to string, rather than we having to call string explicitly?

ref, relref, relURL, relLangURL, absURL, and absLangURL return template.HTML. The original implementations returned a string. It in unclear when/why the change was made, but it may have happened when the template functions were namespaced.

I've been thinking about this, and can't come up with a good reason for the current data type. We added the urls.JoinPath a few months ago, which returns a string.

Although I've never had a problem with the current data type, create an issue if you feel strongly about it.

@willfaught
Copy link
Contributor Author

I'll create an issue. In the meantime, this issue can be for specifying the existing return type of relLangURL.

jmooring added a commit to jmooring/hugo-docs that referenced this issue Oct 1, 2023
jmooring added a commit to jmooring/hugo-docs that referenced this issue Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants