Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including ember-string-parameterize with all npm packages installed. Try it out:

var emberStringParameterize = require("ember-string-parameterize")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ember-string-parameterize v0.2.1

An ember.js extension that transforms a string so that it may be used as part of a 'pretty' / SEO friendly URL.

Ember.String.parameterize Build Status

A javascript method (with an ember.js wrapper) to transform a string so that it may be used as part of a 'pretty' / SEO friendly URL. Similar to ActiveSupport's parameterize inflector.

This is useful for creating slugs for your Ember.js routes. So useful that this feature was merged into Ember core with a feature flag, but later removed due to potential API bloat. Voice your opinion if you want it back, or, just use this!

Usage

Include ember-string-parameterize.js after ember.js in your app.

Or using package managers:

bower install ember-string-parameterize
npm install ember-string-parameterize

Examples

With Ember

'My favorite movies.'.parameterize();
//=> 'my-favorite-movies'

'some_underscored_string'.parameterize();
//=> 'some-underscored-string'

'100 ways Ember.js is better than Angular'.parameterize();
//=> '100-ways-emberjs-is-better-than-angular'

'#emberjs Core Team Meeting Minutes - 2014/12/06'.parameterize();
//=> 'emberjs-core-team-meeting-minutes-2014-12-06'

Limit the number of words

'100 ways Ember.js is better than Angular'.parameterize(5);
//=> '100-ways-emberjs-is-better'

'100 ways Ember.js is better than Angular'.parameterize(-2);
//=> '100-ways-emberjs-is-better'

When Ember.EXTEND_PROTOTYPES is disabled

Ember.String.parameterize('Using without extending prototypes!');
//=> 'using-without-extending-prototypes'

Ember.String.parameterize('Using without extending prototypes!', 3);
//=> 'using-without-extending'

Vanilla JS

It will also expose StringParameterize to the browser's window object or node.js

StringParameterize('I work without Ember.js');
//=> 'i-work-without-emberjs'

StringParameterize('I work without Ember.js', 2);
//=> 'i-work'
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free