Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.toTokenCase

toTokenCase($joiner, $options={}) -> string

Description

Format the string as a single token consisting of all ASCII characters.

The $joiner argument takes a 1-2 character string to join words together.

If $joiner is 'camel', the string is formatted in camelCase.

'profile color id'.toTokenCase('camel')
//= 'profileColorId'

'profile color id'.toTokenCase('-') // aka "kebab-case"
//= 'profile-color-id'

'profile color id'.toTokenCase('_') // aka "snake_case"
//= 'profile_color_id'

'ProfileColorId'.toTokenCase(' ')
//= 'profile color id'

Uppercase Tokens 

If $options is -upper, the token is all uppercase or UpperCamelCase.

'profile color id'.toTokenCase('camel', -upper) // aka "PascalCase"
//= 'ProfileColorId'

'profile color id'.toTokenCase('_') // aka "CONSTANT_CASE"
//= 'PROFILE_COLOR_ID'

See Also