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

Expose <variable> as a field within foreach bodies #81

Open
narenranjit opened this issue Apr 22, 2016 · 0 comments
Open

Expose <variable> as a field within foreach bodies #81

narenranjit opened this issue Apr 22, 2016 · 0 comments

Comments

@narenranjit
Copy link
Contributor

See comments on #79

Q: " How do I do something different for the first or last item in a loop. For example I may want to generate:

1,2,3,4,5 (note - no comma on last item)"

A: "The easier solution than that is:

Flow.dom.converters.register('join', function(v){ return v.join(',') });

<div data-f-bind="somearray | join"> </div>

A more generic/ better solution may be to expose the array itself as a variable.

<ul data-f-foreach="somearray"> 
  <li> <%= (index === somearray.length - 1) ? "last" : value %> </li> 
</ul>
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

1 participant