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

Nested rv-each and indexes #551

Closed
jccazeaux opened this issue Jan 28, 2016 · 3 comments
Closed

Nested rv-each and indexes #551

jccazeaux opened this issue Jan 28, 2016 · 3 comments

Comments

@jccazeaux
Copy link
Contributor

When we have nested rv-each binders, we only have one index. This index is the index of the last rv-each. So we can't us multiple indexes. See this example : https://jsfiddle.net/jccazeaux/cj48q6zq/3/
I cannot access the index of first rv-each

A simple solution would be to not use generic index attribute but a dynamic attribute. This attribute would be %<item>% where <item> represents the current iterated item (rv-each-[item])

In the jsfiddle example, we could access each index like this :

<div id="view">
  <div rv-each-array="model.twoDimensionArray">
    <div rv-each-element="array">
      <span>element #{%array%}.{%element%}  : {element}</span>
    </div>
  </div>
</div>

@stalniy
Copy link
Contributor

stalniy commented Jan 29, 2016

it'd be even better to have something like <item>Index instead of %<item>% as last one is not self-descriptive and it's one more thing to remember about rivets. People always will ask what is the difference between { var } and { %var% }. Moreover somebody possibly uses {% and %} for as options for openinig and closing rivets tags (i.e. templateDelimiters option)

@jccazeaux
Copy link
Contributor Author

Yep your argument is right. I didn't see the possible confusion with custom delimiters. It's easy to change in the pull request.
@blikblum @Leeds-eBooks Do you have an opinion?

@benadamstyles
Copy link
Collaborator

I do think this is a valid issue, I can't decide what the best syntax would be, I do actually quite like the % because there's less chance of a collision with a dev's own property names, but I also agree that it's one more thing to remember. I've replied on the PR anyway, let's continue the discussion there.

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

No branches or pull requests

3 participants