From 1d35c44a17b7c5fc7538376545e03ca0d06f750a Mon Sep 17 00:00:00 2001 From: Richard Livsey Date: Mon, 11 May 2015 21:26:16 +0100 Subject: [PATCH] {{else}} support for components Requires latest Canary - https://github.com/emberjs/ember.js/pull/11084 --- app/templates/components/if-can.hbs | 2 ++ app/templates/components/unless-can.hbs | 2 ++ tests/dummy/app/templates/index.hbs | 20 ++++++++------------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/templates/components/if-can.hbs b/app/templates/components/if-can.hbs index 839b309..3129c33 100644 --- a/app/templates/components/if-can.hbs +++ b/app/templates/components/if-can.hbs @@ -1,3 +1,5 @@ {{#if isAble}} {{yield}} +{{else}} + {{yield to="inverse"}} {{/if}} \ No newline at end of file diff --git a/app/templates/components/unless-can.hbs b/app/templates/components/unless-can.hbs index 6730197..193bbf1 100644 --- a/app/templates/components/unless-can.hbs +++ b/app/templates/components/unless-can.hbs @@ -1,3 +1,5 @@ {{#unless isAble}} {{yield}} +{{else}} + {{yield to="inverse"}} {{/unless}} \ No newline at end of file diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index d3af1ea..7b9a67a 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -2,31 +2,25 @@ {{#if-can "write post"}} -{{/if-can}} - -{{#unless-can "write post"}} +{{else}}

You cannot write a post

-{{/unless-can}} +{{/if-can}}

if with resource

{{#if-can "edit post" post}} -{{/if-can}} - -{{#unless-can "edit post" post}} +{{else}}

You cannot edit this post

-{{/unless-can}} +{{/if-can}}

helper with additional attributes

{{#if-can "change author for post" post author=bob}}

Can change author

-{{/if-can}} - -{{#unless-can "change author for post" post author=bob}} +{{else}}

Can't change author

-{{/unless-can}} +{{/if-can}} {{input value=bob.id id="author-id-input"}} (post author is {{post.author}}) @@ -39,3 +33,5 @@ {{/if}} + +{{session}} {{session.user}} \ No newline at end of file