ember-truth-helpers
Advanced tools
Comparing version 0.0.2 to 0.0.3
import Ember from 'ember'; | ||
function registerHelperIteration1(name, helperFunction) { | ||
//earlier versions of ember with htmlbars used this | ||
Ember.HTMLBars.helpers[name] = Ember.HTMLBars.makeBoundHelper(helperFunction); | ||
} | ||
function registerHelperIteration2(name, helperFunction) { | ||
//registerHelper has been made private as _registerHelper | ||
//this is kept here if anyone is using it | ||
Ember.HTMLBars.registerHelper(name, Ember.HTMLBars.makeBoundHelper(helperFunction)); | ||
} | ||
function registerHelperIteration3(name, helperFunction) { | ||
//latest versin of ember uses this | ||
Ember.HTMLBars._registerHelper(name, Ember.HTMLBars.makeBoundHelper(helperFunction)); | ||
} | ||
export function registerHelper(name, helperFunction) { | ||
if (Ember.HTMLBars._registerHelper) { | ||
Ember.HTMLBars.helpers[name] = Ember.HTMLBars.makeBoundHelper(helperFunction); | ||
if (Ember.HTMLBars.helpers) { | ||
registerHelperIteration1(name, helperFunction); | ||
} else { | ||
registerHelperIteration3(name, helperFunction); | ||
} | ||
} else if (Ember.HTMLBars.registerHelper) { | ||
Ember.HTMLBars.registerHelper(name, Ember.HTMLBars.makeBoundHelper(helperFunction)); | ||
registerHelperIteration2(name, helperFunction); | ||
} | ||
} |
{ | ||
"name": "ember-truth-helpers", | ||
"version": "0.0.2", | ||
"description": "Ember HTMLBars Helpers for {{#if}} & {{#unless}}: not, and, or, eq & is-array", | ||
"version": "0.0.3", | ||
"description": "Ember HTMLBars Helpers for {{if}} & {{unless}}: not, and, or, eq & is-array", | ||
"directories": { | ||
@@ -6,0 +6,0 @@ "doc": "doc", |
@@ -6,39 +6,45 @@ # Ember Truth Helpers for HTMLBars | ||
**`eq`** | ||
```hbs | ||
{{#if (eq 1 2)}} 1 == 2 {{/if}} | ||
{{#unless (eq 1 2)}} 1 != 2 {{/unless}} | ||
``` | ||
{{#if (eq 1 2)}} 1 == 2 {{/if}} | ||
{{#unless (eq 1 2)}} 1 != 2 {{/unless}} | ||
**`not`** | ||
```hbs | ||
{{#if (not hasCrayons)}} I don't have crayons {{/if}} | ||
{{#if (not hasCrayons hasPaper)}} I don't have crayons or paper {{/if}} | ||
``` | ||
{{#if (not hasCrayons)}} I don't have crayons {{/if}} | ||
{{#if (not hasCrayons hasPaper)}} I don't have crayons or paper {{/if}} | ||
**`and`** | ||
```hbs | ||
{{#if (and hasCrayons hasPaper)}} I have crayons and paper {{/if}} | ||
``` | ||
{{#if (and hasCrayons hasPaper)}} I have crayons and paper {{/if}} | ||
**`or`** | ||
```hbs | ||
{{#if (or hasCrayons hasPaper)}} I have something {{/if}} | ||
``` | ||
{{#if (or hasCrayons hasPaper)}} I have something {{/if}} | ||
**`is-array`** | ||
```hbs | ||
{{#if (is-array siblings)}} | ||
{{#each siblings as |sibling|}} | ||
My sibling: {{sibling}} | ||
{{/each}} | ||
{{/if}} | ||
``` | ||
{{#if (is-array siblings)}} | ||
{{#each siblings as |sibling|}} | ||
My sibling: {{sibling}} | ||
{{/each}} | ||
{{/if}} | ||
**`in combination`** | ||
```hbs | ||
{{#if (and (not model.isLoading) model.isError)}} | ||
There was an error loading the model | ||
{{/if}} | ||
``` | ||
{{#if (and (not model.isLoading) model.isError)}} | ||
There was an error loading the model | ||
{{/if}} | ||
**`stand alone`** | ||
```hbs | ||
{{and itsCold myJumper}} | ||
<!--returns `myJumper` if `itsCold` is truthy, otherwise returns `itsCold`--> | ||
``` | ||
{{and itsCold myJumper}} | ||
(returns myJumper if itsCold is truthy, otherwise returns itsCold ('false')) | ||
## Install | ||
@@ -45,0 +51,0 @@ |
28400
489
71