each ... in ... support for ember compat handlebars

This commit is contained in:
Sam 2015-01-07 18:18:26 +11:00
parent 95f9788a77
commit da3da6feee
3 changed files with 16 additions and 5 deletions

View File

@ -38,7 +38,18 @@
}; };
}; };
stringCompatHelper("each"); // #each .. in support
RawHandlebars.registerHelper('each', function(localName,inKeyword,contextName,options){
var list = Em.get(this, contextName);
var output = [];
var innerContext = Object.create(this);
for (var i=0; i<list.length; i++) {
innerContext[localName] = list[i];
output.push(options.fn(innerContext));
}
return output.join('');
});
stringCompatHelper("if"); stringCompatHelper("if");
stringCompatHelper("unless"); stringCompatHelper("unless");
stringCompatHelper("with"); stringCompatHelper("with");

View File

@ -1,5 +1,5 @@
<td class='posters'> <td class='posters'>
{{#each posters}} {{#each poster in posters}}
<a href="{{user.path}}" data-user-card="{{user.username}}" class="{{extras}}">{{avatar this usernamePath="user.username" imageSize="small"}}</a> <a href="{{poster.user.path}}" data-user-card="{{poster.user.username}}" class="{{poster.extras}}">{{avatar poster usernamePath="user.username" imageSize="small"}}</a>
{{/each}} {{/each}}
</td> </td>

View File

@ -1,8 +1,8 @@
{{~#if view.renderDiv ~}} {{~#if view.renderDiv ~}}
<div class='topic-statuses'> <div class='topic-statuses'>
{{/if ~}} {{/if ~}}
{{~#each view.statuses ~}} {{~#each status in view.statuses ~}}
<{{openTag}} title='{{title}}' class='topic-status'><i class='fa fa-{{icon}}'></i></{{closeTag}}> <{{status.openTag}} title='{{status.title}}' class='topic-status'><i class='fa fa-{{status.icon}}'></i></{{status.closeTag}}>
{{~/each}} {{~/each}}
{{~#if view.renderDiv ~}} {{~#if view.renderDiv ~}}
</div> </div>