0

I am totally new in Ember in framework, and in one task stuck up.

I have an array of dates like

["2014-03-15T12:30:00Z", "2014-03-14T12:30:00Z", "2014-03-13T12:30:00Z", "2014-03-05T02:30:00Z", "2014-03-04T12:30:00Z", "2014-03-04T12:30:00Z", "2014-03-03T12:30:00Z", "2014-02-13T12:30:00Z"]

and there is one more array of object of events

I want to create a template which will show events as per dates. I mean all the events on 15th of march should shown under 15th march, like

Today
  Event 1
  Event 2

15th March
  Event 3
  Event 4

Likewise

Here is a code i have used so far

<div class="posts">
 {{#each time in allEventsTimes}}
  {{time}}
   <ul id="posts" class="nav">
     {{#each event in activities}}
       {{if checkDate(event.trackable.startTime time)}}
         {{partial 'user/date_event'}}
       {{/if}} 
     {{/each}}
   </ul>
 {{/each}}
</div>

Where there is a method name "checkDate" which compares "event.trackable.startTime" with "time"

I am able to get result result of "checkDate" method if i use it separately, but if i use it under "if condition" it gives me error that if condition can accept only one argument

Please suggest right direction

Jeet
  • 1,350
  • 1
  • 15
  • 32

1 Answers1

1

Handlebars tried to be a logic-less templating engine, so it will not allow you running a method that way. You can solve it by either:

  • write your own handlebars checkDate helper (and maybe use it as a subexpression in the if helper - or even extend the if helper itself)

or

  • the easier and cleaner way - create the events-by-time list in your controller, and iterate over that.
Meori Oransky
  • 688
  • 4
  • 8
  • in your second suggestion you have said to create events-by-time list, but i am not able to pass time to controller so that i can find event specific to that time. Please suggest how to pass time to controller – Jeet Mar 19 '14 at 11:25
  • Where does "time" comes from now? – Meori Oransky Mar 19 '14 at 13:24