Skip to content

Instantly share code, notes, and snippets.

@Duder-onomy
Created May 14, 2015 21:57
Show Gist options
  • Save Duder-onomy/f94e84c5d26cc720cee2 to your computer and use it in GitHub Desktop.
Save Duder-onomy/f94e84c5d26cc720cee2 to your computer and use it in GitHub Desktop.
Start Case Rivets Formatter
model.someUpperCaseMultiWordString = 'the ONE and ONLY';
<div rv-text='model.someUpperCaseMultiWordString | startCase'></div>

The Binder :

define([], function() {
    'use strict';

    return {
        startCase : startCase
    };

    function startCase(value) { // from DUDER -> Duder
        return value && value.split(' ').map(function(string) {
            return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
        }).join(' ');
    }
});

String becomes:

<div>The One And Only</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment