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

Cannot access .Name in if .HasChildren #8649

Closed
Corfucinas opened this issue Jun 15, 2021 · 3 comments
Closed

Cannot access .Name in if .HasChildren #8649

Corfucinas opened this issue Jun 15, 2021 · 3 comments

Comments

@Corfucinas
Copy link

What version of Hugo are you using (hugo version)?

hugo v0.84.0-DEV+extended linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes, commit d392893cd7 has the problem


Seems pulling the latest commit on master has some bug, building my website with commit d392893cd7 makes this code not produce anything

<ul class="navbar-nav">
          {{ range .Site.Menus.main }}
          {{ if .HasChildren }}
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true"
              aria-expanded="false">
              {{ .Name }}
            </a>
            <div class="dropdown-menu">
              {{ range .Children }}
              <a class="dropdown-item" href="{{ .URL | absURL }}">{{ .Name }}</a>
              {{ end }}
            </div>
          </li>
          {{ else }}
          <li class="nav-item">
            <a class="nav-link" href="{{ .URL | absURL }}">{{ .Name }}</a>
          </li>
          {{ end }}
          {{ end }}
        </ul>

Section is missing

image

But if I build it with the previous commit a886dd53b8032 , it works

image

@jmooring
Copy link
Member

jmooring commented Jun 15, 2021

I was not able to reproduce this problem with d392893 when the menu entries are defined in the site configuration.

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

EDIT: Pushed changes at 2021-06-15T06:48:17-07:00

@bep
Copy link
Member

bep commented Jun 15, 2021

@Corfucinas can you please clean up the title of this issue; a short description about what the issue is about, remove any conclusion/label ("bug") and commit reference. Thank you.

@jmooring jmooring changed the title Commit d392893cd7 bug - cannot access .Name in if .HasChildren Cannot access .Name in if .HasChildren Jun 17, 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 19, 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