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

Unable to detect nil explicitly in where func #6015

Closed
RealOrangeOne opened this issue Jun 3, 2019 · 2 comments
Closed

Unable to detect nil explicitly in where func #6015

RealOrangeOne opened this issue Jun 3, 2019 · 2 comments

Comments

@RealOrangeOne
Copy link
Contributor

Originally opened as #5905. The fix implemented in 66b143a doesn't seem to fix the issue.

The below code:

{{ range where .Site.Pages.ByTitle ".Parent" "!=" nil }}
        <p>{{ .Parent }} {{ eq .Parent nil }}</p>
{{ end }}

yields many lines with <nil> false, meaning nil != nil in both eqand where. The pages affected seem to all be either taxonomy / taxonomy terms.

My current fix is to do:

{{ range .Site.Pages.ByTitle }}
  {{ if .Parent }}
    <p>{{ .Parent }}</p>
  {{ end }}
{{ end }}

Which makes me think it is probably caused by the fun which is nil equality checking in Go!

image

Running Hugo Static Site Generator v0.55.6/extended linux/amd64 BuildDate: unknown

@bep bep changed the title Unable to detect nil explicitly in conditionals Unable to detect nil explicitly in where func Jun 3, 2019
@bep bep added this to the v0.56 milestone Jun 3, 2019
@bep bep modified the milestones: v0.56, v0.57, v0.58 Jul 26, 2019
@bep bep modified the milestones: v0.58, v0.59 Aug 13, 2019
@bep bep modified the milestones: v0.59, v0.60 Sep 6, 2019
@bep bep modified the milestones: v0.60, v0.61 Oct 21, 2019
@bep bep modified the milestones: v0.61, v0.62, v0.63 Nov 25, 2019
@bep bep modified the milestones: v0.63, v0.64 Dec 11, 2019
@bep bep modified the milestones: v0.64, v0.65 Jan 22, 2020
@bep bep modified the milestones: v0.65, v0.66 Jan 30, 2020
@bep bep modified the milestones: v0.66, v0.67 Mar 2, 2020
@bep bep modified the milestones: v0.67, v0.68 Mar 9, 2020
@bep bep modified the milestones: v0.68, v0.69 Mar 20, 2020
@bep bep modified the milestones: v0.69, v0.70 Apr 8, 2020
@bep bep modified the milestones: v0.70, v0.71 Apr 28, 2020
@bep bep modified the milestones: v0.71, v0.72 May 18, 2020
@bep bep modified the milestones: v0.72, v0.73 May 31, 2020
@bep bep modified the milestones: v0.73, v0.74 Jun 23, 2020
@bep bep modified the milestones: v0.74, v0.75 Jul 13, 2020
@bep bep modified the milestones: v0.75, v0.76 Sep 14, 2020
@bep bep modified the milestones: v0.76, v0.77 Oct 6, 2020
@bep bep modified the milestones: v0.77, v0.78 Oct 30, 2020
@bep bep modified the milestones: v0.78, v0.83 Apr 23, 2021
@jmooring
Copy link
Member

jmooring commented May 1, 2021

This code:

{{ range where .Site.Pages.ByTitle ".Parent" "!=" nil }}
  <p>{{ .Parent }} {{ eq .Parent nil }}</p>
{{ end }}

should only produce lines ending with false, which it does.

git clone --single-branch -b hugo-github-issue-6015 https://github.com/jmooring/hugo-testing hugo-github-issue-6015
cd hugo-github-issue-6015
hugo server

@jmooring jmooring closed this as completed May 1, 2021
@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 Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants