Skip to content

Commit

Permalink
{{else}} support for components
Browse files Browse the repository at this point in the history
Requires latest Canary - emberjs/ember.js#11084
  • Loading branch information
rlivsey committed May 11, 2015
1 parent 4339baa commit 1d35c44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions app/templates/components/if-can.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{#if isAble}}
{{yield}}
{{else}}
{{yield to="inverse"}}
{{/if}}
2 changes: 2 additions & 0 deletions app/templates/components/unless-can.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{#unless isAble}}
{{yield}}
{{else}}
{{yield to="inverse"}}
{{/unless}}
20 changes: 8 additions & 12 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,25 @@

{{#if-can "write post"}}
<button id="write-post">Write</button>
{{/if-can}}

{{#unless-can "write post"}}
{{else}}
<p id="cant-write">You cannot write a post</p>
{{/unless-can}}
{{/if-can}}

<h2>if with resource</h2>

{{#if-can "edit post" post}}
<button id="edit-post">Edit</button>
{{/if-can}}

{{#unless-can "edit post" post}}
{{else}}
<p id="cant-edit">You cannot edit this post</p>
{{/unless-can}}
{{/if-can}}

<h2>helper with additional attributes</h2>

{{#if-can "change author for post" post author=bob}}
<p id="can-with-additional">Can change author</p>
{{/if-can}}

{{#unless-can "change author for post" post author=bob}}
{{else}}
<p id="cant-with-additional">Can't change author</p>
{{/unless-can}}
{{/if-can}}

{{input value=bob.id id="author-id-input"}} (post author is {{post.author}})

Expand All @@ -39,3 +33,5 @@
{{/if}}

<button {{action "selectEditable"}} id="select-editable">Editable Post</button> <button {{action "selectOther"}} id="select-non-editable">Another Post</button>

{{session}} {{session.user}}

0 comments on commit 1d35c44

Please sign in to comment.