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?
-
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
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:
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.
-
truncate
andpluralize
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