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

Support Handlebars @key and @index directives #383

Closed
daffl opened this issue May 7, 2013 · 10 comments
Closed

Support Handlebars @key and @index directives #383

daffl opened this issue May 7, 2013 · 10 comments
Milestone

Comments

@daffl
Copy link
Contributor

daffl commented May 7, 2013

Handlebars supports {{@key}} and {{@index}} directives when iterating over an object.

See here on Stackoverflow. I think it would be a good feature to add.

@wclr
Copy link
Contributor

wclr commented May 15, 2013

definitely +

@ekryski
Copy link
Contributor

ekryski commented Jul 23, 2013

+1

@azazel75
Copy link

azazel75 commented Oct 3, 2013

it would be very helpful

@wclr
Copy link
Contributor

wclr commented Oct 16, 2013

Wasn't it implemented yet?

@ghost ghost assigned imjoshdean Nov 6, 2013
@imjoshdean
Copy link
Contributor

I've been working on this and have been overall happy with what I have. After talking with @daffl, expect the 2.1 launch to have a lot of goodies related to this such as:

  • @index directive which outputs the index of item of an array/can.List
  • @key directive which outputs the name of properties on objects and attribute names on can.Maps
  • #each iterator now works on generic objects as well as can.Maps
  • #each will be live bound on can.Map attributes
  • @index will be live bound on can.List

Unrelated but it will also have an implementation of {{log}} which will log the current context of where it appears in the template.

You can play with it in the indexKeyLogMustache branch.

@justinbmeyer
Copy link
Contributor

This should work with the branch I just added that rewrites scope.

Sent from my iPhone

On Nov 7, 2013, at 11:12 AM, Josh Dean notifications@github.com wrote:

I've been working on this and have been overall happy with what I have. After talking with @daffl, expect the 2.1 launch to have a lot of goodies related to this such as:

@Index directive which outputs the index of item of an array/can.List
@key directive which outputs the name of properties on objects and attribute names on can.Maps
#each iterator now works on generic objects as well as can.Maps
#each will be live bound on can.Map attributes
@Index will be live bound on can.List
Unrelated but it will also have an implementation of {{log}} which will log the current context of where it appears in the template.

You can play with it in the indexKeyLogMustache branch.


Reply to this email directly or view it on GitHub.

@imjoshdean
Copy link
Contributor

@justinbmeyer Perhaps it's time we start a 2.1-dev branch?

@daffl
Copy link
Contributor Author

daffl commented Nov 7, 2013

We probaby should have a general dev branch for the next minor/major version so that we can keep master at the patch level.

@justinbmeyer
Copy link
Contributor

agreed, a dev branch. There were a lot of minor breaking changes I wanted
to make to can.Component.

Justin Meyer
847-924-6039

On Thu, Nov 7, 2013 at 12:16 PM, David Luecke notifications@github.comwrote:

We probaby should have a general dev branch for the next minor/major
version so that we can keep master at the patch level.


Reply to this email directly or view it on GitHubhttps://github.com//issues/383#issuecomment-27991519
.

@imjoshdean
Copy link
Contributor

So, in a surprise turn of events Christmas is coming early and this is going to be in 2.0.1. Here is an example of it in action: http://jsfiddle.net/7Kxtu/7/

If you're on master, pull away and enjoy.

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

6 participants