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

{{#each}} not working when using renameKey #862

Closed
mfwonghk opened this issue May 24, 2016 · 15 comments
Closed

{{#each}} not working when using renameKey #862

mfwonghk opened this issue May 24, 2016 · 15 comments
Labels

Comments

@mfwonghk
Copy link

mfwonghk commented May 24, 2016

Hi,

In my partials nav.hbs, I have a menu like this:

{{#pages}}
  {{#each items}}
    <a href="{{link-to key}}">{{data.title}}</a>
  {{/each}}
{{/pages}}

When not using any renameKey function it is rendered correctly. However if I add the following in my assemblefile.js

app.option('renameKey', function(key) {
  return path.basename(key, path.extname(key));  // Just using the default function as example
});

app.create('pages');

then nothing is rendered.

Strange, if I change the view collection name to something other than pages then it works again. Like this:

{{#posts}}
  {{#each items}}
    <a href="{{link-to key 'posts'}}">{{data.title}}</a>
  {{/each}}
{{/posts}}

I can use other name for now, but I am curious why it is not working with built-in view collection pages?

Thanks again for your help 😄

P.S. @assemblebot I am using 0.12.0

@assemblebot
Copy link

@mfwonghk 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.

If your issue is related to one of the following, please open an issue there:

  • grunt-assemble Issues with using assemble in grunt or the grunt-assemble library.
  • handlebars-helpers Issues with using handlebars helpers from the handlebars-helpers library.

@jonschlinkert
Copy link
Member

I can use other name for now, but I am curious why it is not working with built-in view collection pages?

sounds like a bug. hmm, if I remember correctly we're creating a new List (List is an array, Views is an object) for the collection helpers. my hunch is that the key isn't being updated when a new Item is created on the list. I'll look into it, thanks for the issue

@jonschlinkert
Copy link
Member

actually, where is the each helper from? built-in or custom (ours/yours)?

@mfwonghk
Copy link
Author

It's a built in helper. I am still learning how to build my custom one.

@jonschlinkert
Copy link
Member

I'm sure this issue isn't making it any easier lol. thanks for the feedback

@mfwonghk
Copy link
Author

Thanks for your quick response! :)

@jonschlinkert
Copy link
Member

jonschlinkert commented May 28, 2016

Sorry for the delay, I should been more specific with my question, what repo is the helper from? Is it handlebars-helpers or https://github.com/assemble/assemble-handlebars-helpers?

If you could, please create an issue on the helper repo. feel free to link back to this one. Closing here since this isn't an assemble issue

@mfwonghk
Copy link
Author

Actually I didn't install or link any helper in my assemblefile.js. 😅
I guess by installing assemble I am by default using assemble-handlebars-helpers?

@jonschlinkert
Copy link
Member

I'm an idiot... reopening lol.

@jonschlinkert jonschlinkert reopened this May 28, 2016
@jonschlinkert
Copy link
Member

handlebars has built-in helpers. I guess I was transfixed on our own helpers. I'll look into it and see what's happening

@mfwonghk
Copy link
Author

I did another test by installing assemble-handlebars-helpers and added this in my assemblefile.js

app.helpers(require('assemble-handlebars-helpers'));

Same result. No menu when using pages.

@mfwonghk
Copy link
Author

My repo, if it helps: https://github.com/mfwonghk/assemble-playground

@jonschlinkert
Copy link
Member

yes that definitely helps, thanks! I'll take a look as soon as I have a chance

@grayghostvisuals
Copy link

@mfwonghk are you still in need of assistance? The ticket has been open for over 1 year with nothing resolved as of today

@mfwonghk
Copy link
Author

It seems this issue is fixed. 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

4 participants