Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-class-names-helper

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-class-names-helper

Template helper for conditionally joining class names.

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

{{class-names}} helper

CI status NPM version

Provides a cleaner way for conditionally joining class names in templates.

Before:

<button class="button {{if @primary "button--primary"}} {{if @small "button--small"}} {{if @disabled "is-disabled"}}" type="button">
  Submit
</button>

After:

<button
  class={{class-names
    "button"
    button--primary=@primary
    button--small=@small
    is-disabled=@disabled
  }}
  type="button"
>
  Submit
</button>

Or with {{cn}} alias in a single line:

<button
  class={{cn "button" button--primary=@primary button--small=@small is-disabled=@disabled}}
  type="button"
>
  Submit
</button>

Installation

ember install ember-class-names-helper

The helper relies on a tiny and well-tested library classnames.

Usage

<button
  class={{class-names
    "button"
    (if @fancy "bg-white rounded-lg p-6")
    button--primary=@primary
    is-disabled=@disabled
  }}
  type="button"
/>

Or with {{cn}} alias:

<button
  class={{cn "button" is-disabled=@disabled}}
  type="button"
/>

Compatibility

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 25 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc