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

How to access index in rv-each? #9

Closed
trollkotze opened this issue Jun 22, 2018 · 3 comments
Closed

How to access index in rv-each? #9

trollkotze opened this issue Jun 22, 2018 · 3 comments

Comments

@trollkotze
Copy link

trollkotze commented Jun 22, 2018

The documentation says under "Differences from rivets.js":

Change how scope of iteration binder works. Instead of copying properties down to children, uses a prototype like approach

Related: 486 512 417
Change how to customize index name in each binder (using an attribute)
Related: 551 552

Issue 551 and pull-request 552 from rivets.js, which are referred to here, talk about this feature, but it's not clear how (and if) it is implemented in tinybind. The rivets.js generic { index } does not work, nor the other syntax { %item% } that was later added in rivets.

Is it possible to access the iteration index inside rv-each in tinybind?

@trollkotze
Copy link
Author

Oh, I found it. The syntax is {$index}.

Found it in the example.

But what about nested indexes? Rivets.js has this syntax now:

<ul rv-each-whatever="items">
  <li>{ %items% }: whatever</li>
</ul>

The index of the iterated array items here can be accessed with { %items% }. In this way, it is possible to distinguish indexes of nested rv-each iterations.

Is something like that also possible in tinybind?

@trollkotze
Copy link
Author

Oh, I see. That's how it works:

<ul rv-each-whatever="items" index-property="something">
  <li>{ something }: whatever</li>
</ul>

Would be worth documenting, I think.

@blikblum
Copy link
Owner

Added docs in a57e594

Should be online soon

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

2 participants