4

It would be great to have helpers like linkTo(), truncate(), and pluralize() in Javascript. Have there been any efforts to port some or all of Rails' view helpers to Javascript?

1
  • Myself, I’d love to see the functions for formatting numbers (with delimiters or like “55.2M”)
    – Alan H.
    May 16, 2012 at 0:08

1 Answer 1

2

If you just need one or two, you can find snippets for pluralize and singularize or another for truncating.

And actually, there's now a javascript library that handles a lot of the syntactic sugar:

Sugar.js

Like I said in my original post, no need to include a whole library if you only want one or two of them or can manage to just use the Rails helpers, but the option to have them is out there.

1
  • truncate and pluralize are probably bad examples if you want to argue they would hurt load time significantly. Those are pretty tiny, unless of course we are assuming there’s also a large embedded list of known irregular plurals… in which case, we’re in agreement
    – Alan H.
    May 16, 2012 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.