ember-polyfills / ember-angle-bracket-invocation-polyfill

MIT License
76 stars 33 forks source link

ember-angle-bracket-invocation-polyfill

This addon provides a polyfill for angle bracket invocation syntax as described in RFC 311 and RFC 457. It's the same components you know and love, no longer surrounded by mustaches. \o/

Build Status

Installation

ember install ember-angle-bracket-invocation-polyfill

You will additionally need to ensure ember-cli-htmlbars-inline-precompile is at least version 1.0.3.

Usage

The best usage guide are the RFCs themselves (emberjs/rfcs#311 emberjs/rfcs#457), but here are a few examples of "before"/"after" to whet your appetite:

Before:

{{site-header user=this.user class=(if this.user.isAdmin "admin")}}

{{#super-select selected=this.user.country as |s|}}
  {{#each this.availableCountries as |country|}}
    {{#s.option value=country}}{{country.name}}{{/s.option}}
  {{/each}}
{{/super-select}}

After:

<SiteHeader @user={{this.user}} class={{if this.user.isAdmin "admin"}} />

<SuperSelect @selected={{this.user.country}} as |s|>
  {{#each this.availableCountries as |country|}}
    <s.option @value={{country}}>{{country.name}}</s.option>
  {{/each}}
</SuperSelect>

Supported Features

<FooBar></FooBar>
<FooBar />
<some.thing></some.thing>
{{#with (component 'foo-bar') as |Foo|}}
  <Foo></Foo>
{{/with}}
<FooBar @title={{whateverHere}}></FooBar>
<FooBar data-test-foo-bar></FooBar>
<FooBar /> {{! checking `has-block` inside would be `false`}}

<FooBar></FooBar> {{! checking `has-block` inside would be `true`}}
<FooBar as |qux|>{{qux}}</FooBar>
<FooBar ...attributes>
<div ...attributes></div>
<Title />
<Foo::Bar />

Addons

Any addons wanting to use angle bracket components (in either addon/ or addon-test-support/) need to install ember-angle-bracket-invocation-polyfill as a dependency.

Limitations

There are no known limitations, all features described in the RFC are polyfilled.

Contributing

Installation

Linting

Running tests

Running the dummy application

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

License

This project is licensed under the MIT License.