Template helper for conditionally joining class names.
npm install ember-class-names-helper{{class-names}} helperProvides a cleaner way for conditionally joining class names in templates.
Before:
``hbs`
After:
`hbs`
class={{class-names
"button"
button--primary=@primary
button--small=@small
is-disabled=@disabled
}}
type="button"
>
Submit
Or with {{cn}} alias in a single line:
`hbs`
class={{cn "button" button--primary=@primary button--small=@small is-disabled=@disabled}}
type="button"
>
Submit
``
ember install ember-class-names-helper
The helper relies on a tiny and well-tested library classnames.
`hbs`
class={{class-names
"button"
(if @fancy "bg-white rounded-lg p-6")
button--primary=@primary
is-disabled=@disabled
}}
type="button"
/>
Or with {{cn}} alias:
`hbs``
class={{cn "button" is-disabled=@disabled}}
type="button"
/>
* Ember.js v3.20 or above
* Ember CLI v3.20 or above
* Node.js v12 or above
See the Contributing guide for details.
This project is licensed under the MIT License.