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

Add "param" shortcode #4010

Closed
bep opened this issue Oct 26, 2017 · 6 comments · Fixed by #5477
Closed

Add "param" shortcode #4010

bep opened this issue Oct 26, 2017 · 6 comments · Fixed by #5477
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Oct 26, 2017

Looking something like this:

{{- $name := .Get 0 -}}
{{- with (.Page.Param $name }}{{ . }}{{ else }}{{ errorf "param %q not found in %q" $name .Page.Path }}{{ end -}} 
@bep bep added this to the v0.31 milestone Oct 26, 2017
@kaushalmodi
Copy link
Contributor

Should there be a site params alternative too? Maybe pparam and sparam?

@bep
Copy link
Member Author

bep commented Oct 26, 2017

Should there be a site params alternative too? Maybe pparam and sparam?

I assume you know that the above snippet will fall back to Site param if not found in Page. This is the common requirement. I don't want to add more until I see some neon ads on Time Square in New York saying "we want pparam in Hugo now!" It adds documentation work and those people who really need it can easily add it themselves.

@bep
Copy link
Member Author

bep commented Oct 26, 2017

That said, this shortcode should probably have an optional second argument with a default value if not found.

@kaushalmodi
Copy link
Contributor

I assume you know that the above snippet will fall back to Site param if not found in Page.

Yes, I read about there somewhere in the docs. But I got misled by the error message {{ errorf "param %q not found in %q" $name .Page.Path }}. Should the error then say that that $name param was not found in both .Site and .Page params?

this shortcode should probably have an optional second argument with a default value if not found.

That will be cool!

@bep
Copy link
Member Author

bep commented Oct 26, 2017

Should the error then say that that $name param was not found in both .Site and .Page params?

This is an issue asking for a shortcode. This is not the implementation. I quickly wrote that error text and it could be cluearer, but the important info elements are the name of the param and the page path ... Then it should be easy to navigate.

@bep bep modified the milestones: v0.31, v0.32 Oct 30, 2017
@bep bep modified the milestones: v0.32, v0.33 Dec 16, 2017
@bep bep modified the milestones: v0.33, v0.34 Jan 11, 2018
@bep bep modified the milestones: v0.34, v0.35, v0.36 Jan 22, 2018
@bep bep modified the milestones: v0.36, v0.37 Feb 3, 2018
@bep bep modified the milestones: v0.37, v0.38 Feb 11, 2018
@bep bep modified the milestones: v0.38, v0.39 Feb 21, 2018
@bep bep modified the milestones: v0.39, v0.40 Apr 9, 2018
@bep bep modified the milestones: v0.40, v0.41 Apr 20, 2018
@bep bep removed this from the v0.41 milestone May 4, 2018
@bep bep added this to the v0.43 milestone Jun 5, 2018
@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018
@bep bep modified the milestones: v0.44, v0.45, v0.46 Jul 10, 2018
@bep bep modified the milestones: v0.46, v0.47, v0.48 Aug 3, 2018
@bep bep modified the milestones: v0.48, v0.49 Aug 22, 2018
@bep bep modified the milestones: v0.49, v0.50 Sep 13, 2018
@bep bep modified the milestones: v0.50, v0.51 Oct 6, 2018
@bep bep modified the milestones: v0.51, v0.53 Nov 8, 2018
@bep bep self-assigned this Nov 26, 2018
@bep bep modified the milestones: v0.53, v0.52 Nov 26, 2018
bep added a commit to bep/hugo that referenced this issue Nov 27, 2018
@bep bep closed this as completed in #5477 Nov 27, 2018
bep added a commit that referenced this issue Nov 27, 2018
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants