#152 new
Douwe M.

String#ucfirst?

Reported by Douwe M. | January 2nd, 2010 @ 08:15 PM

Maybe a String#ucfirst method could be implemented, to capitalize the first character in a String, just like String#capitalize capitalizes the whole string.

Comments and changes to this ticket

  • MadRabbit

    MadRabbit January 2nd, 2010 @ 08:40 PM

    Not in the core. There's a whole bunch of additional handy methods over there, and we can't put all of them into the core or we end up with a fat framework and holly mess of methods.

    For this reason there is another plugin called 'lang' that supposedly should keep all additional features and methods for the native units (there are few other similar tickets hanging around). But it wasn't properly developed yet, coz there are more important things to do now.

  • Douwe M.

    Douwe M. January 2nd, 2010 @ 08:58 PM

    Okay, I agree. I thought it would be the same as the #capitalize method, that basically is a mask to #toUpperCase, but then I realized that wasn't true, as #capitalize works for Russian letters too.

  • MadRabbit

    MadRabbit January 2nd, 2010 @ 09:16 PM

    it is actually pretty easy to hack rightjs, if you need this method, you can easily implement it for your case, just like that

    
    $ext(String.prototype, {
      ucfirst: function() {
        return this.replace(/^\s*[a-z]/, function(match) { return match.toUpperCase(); });
      }
    });
    
  • Douwe M.

    Douwe M. January 2nd, 2010 @ 09:20 PM

    Already did myself ;-)

    Which makes me think of this:
    Maybe you could implement the date() function from phpjs.org (at http://phpjs.org/functions/date:380) as Date#format() ? Did that myself already via the $ext() function, but I think this would be a really nice feature to have built right into RightJS, as it actually adds something, unlike ucfirst().

  • MadRabbit

    MadRabbit January 2nd, 2010 @ 09:29 PM

    there is already a ticket for that, but with two corrections, it will follow the POSIX standard not PHP,
    and again it will go in a plugin.

    We will include in the actual core only the things that are necessary for something like 99% of cases. All the fancy features will go in plugins, which can be easily built into the core on the site.

  • Douwe M.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

RightJS Core Tickets

Shared Ticket Bins

People watching this ticket

Pages