If you are familiar with Django you are familiar with a nice set of template tags called "humanize". In essence it turns data such as "13 April 2012" into "2 days ago" or "1000000000" into "1.0 billion". JS Humanizer is a jQuery counterpart to the Django humanize template tags we wrote and thought that others might find it useful too.
Is it possible to have these in a stand alone library/namespace without the need for bringing the whole of jQuery with it? Not everyone uses jQuery in their JS application and it certainly would aid those who perform server-side JS.
Nice idea, but seems to lack of any input escaping.<p><pre><code> => Humanize.truncatechars("<script>alert('yo');<\/script>", 30)
"<script>alert('yo');</script>"
=> Humanize.linebreaks("<script>alert('yo');<\/script>")
"<p><script>alert('yo');</script></p>"
</code></pre>
Bug filed.
This is great! I love how it aligns with the Django templating system as well =) Although I do agree that this might be better off a something that is framework independent. A while ago I posted an example on Forrst of how you might write a simple and pure-js shorten function: <a href="https://forrst.com/posts/JavaScript_Shorten_Function-1up" rel="nofollow">https://forrst.com/posts/JavaScript_Shorten_Function-1up</a>