Support Handlebars @key and @index directives #383

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

Comments

Projects
None yet
6 participants
@daffl
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.

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor May 15, 2013

Contributor

definitely +

Contributor

whitecolor commented May 15, 2013

definitely +

@ekryski

This comment has been minimized.

Show comment
Hide comment
@ekryski

ekryski Jul 23, 2013

Contributor

+1

Contributor

ekryski commented Jul 23, 2013

+1

@azazel75

This comment has been minimized.

Show comment
Hide comment
@azazel75

azazel75 Oct 3, 2013

it would be very helpful

azazel75 commented Oct 3, 2013

it would be very helpful

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Oct 16, 2013

Contributor

Wasn't it implemented yet?

Contributor

whitecolor commented Oct 16, 2013

Wasn't it implemented yet?

@ghost ghost assigned imjoshdean Nov 6, 2013

@imjoshdean

This comment has been minimized.

Show comment
Hide comment
@imjoshdean

imjoshdean Nov 7, 2013

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.

Contributor

imjoshdean commented Nov 7, 2013

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Nov 7, 2013

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.

Contributor

justinbmeyer commented Nov 7, 2013

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

This comment has been minimized.

Show comment
Hide comment
@imjoshdean

imjoshdean Nov 7, 2013

Contributor

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

Contributor

imjoshdean commented Nov 7, 2013

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

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Nov 7, 2013

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Nov 7, 2013

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/bitovi/canjs/issues/383#issuecomment-27991519
.

Contributor

justinbmeyer commented Nov 7, 2013

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/bitovi/canjs/issues/383#issuecomment-27991519
.

@imjoshdean

This comment has been minimized.

Show comment
Hide comment
@imjoshdean

imjoshdean Nov 7, 2013

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.

Contributor

imjoshdean commented Nov 7, 2013

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