Most of you probably already know this but here it is anyway. Ember has a built-in dasherize function that replaces underscores, spaces, or camelCase with dashes.
Here are examples straight from the ember docs:
'innerHTML'.dasherize(); // 'inner-html'
'action_name'.dasherize(); // 'action-name'
'css-class-name'.dasherize(); // 'css-class-name'
'my favorite items'.dasherize(); // 'my-favorite-items'
'privateDocs/ownerInvoice'.dasherize(); // 'private-docs/owner-invoice
Originally published at Ember Daily Tips.