Reputation: 1574
I have a simple blog in which I learn Ember.
Now I have a controller
App.IndexController = Ember.ArrayController.extend({
sortProperties: ['originalId:desc']
sortedPosts: Ember.computed.sort('model', 'sortProperties'),
})
So in template I show all posts. For this I want to show edit link near all of my posts.
So question is how to do this in handlebars.
I want to do something like this:
{{#each post in sortedPosts}}
<h1>{{link-to post.title 'post' post }}</h1>
{{#if session.isAuthenticated and post.ownedBy(session.user)}} <!--This place doesn't work-->
{{link-to 'Edit' 'post.edit' post }}
{{/if}}
{{{post.text}}}
<hr/>
{{/each}}
I found this question Logical operator in a handlebars.js {{#if}} conditional but I hope that there is better solution.
P.S.: There is one more question about sorting with SortableMixin. It doesn't reload templates when sortProperties
is changed. So I have to create one more property sortedPosts
. Maybe someone knows why it doesn't work?
Upvotes: 1
Views: 54