Create variable bindings inside your handlebars templates
Clone or download
Latest commit b668326 Nov 7, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add Code of Conduct, README badges, and Issue Template Jul 20, 2016
addon Fix Ember 2.15+ (#45) Dec 27, 2017
app Created vendor file for ember-let Sep 2, 2016
config Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
lib Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
tests Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
vendor/ember-let Fix Ember 2.15+ (#45) Dec 27, 2017
.bowerrc Initial Commit from Ember CLI v2.6.2 Jul 13, 2016
.editorconfig Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
.ember-cli Initial Commit from Ember CLI v2.6.2 Jul 13, 2016
.eslintrc.js Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
.gitignore Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
.jshintrc Initial Commit from Ember CLI v2.6.2 Jul 13, 2016
.npmignore Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
.travis.yml Bump up node on travis Nov 7, 2018
.watchmanconfig Initial Commit from Ember CLI v2.6.2 Jul 13, 2016
CHANGELOG.md Update CHANGELOG.md Feb 14, 2018
CODE_OF_CONDUCT.md Add Code of Conduct, README badges, and Issue Template Jul 20, 2016
LICENSE.md Initial Commit from Ember CLI v2.6.2 Jul 13, 2016
README.md Update README.md Sep 7, 2016
bower.json Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
ember-cli-build.js Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
index.js fix: Supports ember-engines. Nov 6, 2018
package.json Released v0.7.1 Feb 14, 2018
testem.js Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018
yarn.lock Upgrade Ember-CLI to 2.18.x (#48) Feb 13, 2018

README.md

ember-let

npm version Ember Observer Score Build Status

ember-let is an addon for binding variables to template contexts in Ember. It behaves much like the with helper, but lets you bind an arbitrary number of variables, including standalone values, hashes, and class instances. However, unlike with, the let helper will yield its block even if the bound values are undefined, null, or []. This has the benefit of allowing the user to treat the block values as true variable bindings rather than simply aliases to existing values.

See examples below:

Bind basic values

{{#let "abc" "123" as |first second|}}
  <li>{{first}}</li>
  <li>{{second}}</li>
{{/let}}

Mix hashes and standalone values

{{#let (hash first="first" second="second") "third" as |hash standalone|}}
  <li>{{hash.first}}</li>
  <li>{{hash.second}}</li>
  <li>{{standalone}}</li>
{{/let}}

Bind a class instance returned from a helper

{{#let (boolean) as |bool|}}
  {{bool.value}} - <button onClick={{action bool.toggle}}>toggle</button>
{{/let}}

Inline use Note: requires Ember 2.0+ (ie. does not support 1.13)

{{let greeting=(concat "hello " to)}}
{{greeting}} - <button {{action (action (mut to) "world")}}>Greet the world!</button>  

Inline let declarations are in scope until the parent element or block is closed, for example:

{{#if person.isActive}}
  <div>
    {{let name=person.name}}
    <span>{{name}}</span>
  </div>
  {{!-- The name binding is not accessible here... --}}
{{/if}}
{{!-- ...or here. -- }}

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms, which can be found in the CODE_OF_CONDUCT.md file in this repository.