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

@key in default helper in partial is undefined #41

Closed
spenat28 opened this issue Apr 6, 2016 · 4 comments
Closed

@key in default helper in partial is undefined #41

spenat28 opened this issue Apr 6, 2016 · 4 comments
Labels

Comments

@spenat28
Copy link

spenat28 commented Apr 6, 2016

Hi,
i have an issue with default helper EACH and undefined @key - maybe I am doing something wrong but not sure what.

I have some data file - in JSON.
Its loaded and has following structure:

{
  "projects": {
    "someKey": { "data": "Test data line" },
    "otherKey": { "data": ... },
    ...
  }
}

I have pages and partials, its okay and working just fine on multiple projects. When i use this code in page:

{{#each dataFile.projects}}
    <h1>{{@key}}</h1>
    {{this.data}}
{{/each}}

It renders correctly headers with text "someKey", "otherKey". And text "Test data line", ...

When i move this into partial and use same code, it renders *empty * headers, and text "Test data line" (this is okay) ... i assume they are undefined. But why, and why exactly is it working differently than in page itself?

Code of my page - which extends almost empty layout (my layout seem not important for current issue)

{{#extend "@content"}}
  {{#content "#page"}}
    {{> somePartial }}
  {{/content}}
{{/extend}}

In this i had originaly each block - which was working and when i moved it into separate partial like this - its not working anymore ...

Can You help me? Thanks.

Maybe its an issue, maybe my misunderstanding of something.. ..

I am using version provided by "grunt-assemble": "^0.4.0"
my assemble task pastebin

@assemblebot
Copy link

@spenat28 Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

@doowb
Copy link
Member

doowb commented Apr 6, 2016

I've tested some things out:

  • Using the projects property in a page and in a partial displays the correct data:
{{#each projects}}
  {{@key}}: {{this.data}}
{{/each}}

{{> each-partial }}
  someKey:Test data line
  otherKey:Other data line

  someKey:Test data line
  otherKey:Other data line
  • Using the projects property only in a partial does not display the correct data
{{> each-partial }}
  :Test data line
  :Other data line

I'm not sure of the exact cause of this yet, but I labeled it as a bug so someone can take a look.

@doowb
Copy link
Member

doowb commented Sep 6, 2016

@spenat28 I just published grunt-assemble@0.5.0. Will you get that and try it? I think that it'll fix this issue.

@spenat28
Copy link
Author

@doowb great it resolved this issue. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants