

JS Humanize (Give data a human touch) - mvrekic
https://github.com/milanvrekic/JS-humanize
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.
======
callumjones
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.

~~~
mvrekic
jQuery bit was originally intended to make it compatible with require.js
loading; chetan51, Groxx - thanks for pointing it out. We removed that bit but
we missed the dependancy, removed now thanks to chetan51

~~~
dominicrodger
Nice work! Might want to update the README - it's no longer a jQuery plugin.

------
ctz

      filesizeformat (1234567890 = 1.15 Gb)
    

This should be either 9.20 Gb or 1.15 GB.

------
sirn
Nice idea, but seems to lack of any input escaping.

    
    
        => Humanize.truncatechars("<script>alert('yo');<\/script>", 30)
           "<script>alert('yo');</script>"
    
        => Humanize.linebreaks("<script>alert('yo');<\/script>")
           "<p><script>alert('yo');</script></p>"
    

Bug filed.

~~~
mvrekic
Thanks. I am on it.

------
whalesalad
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:
<https://forrst.com/posts/JavaScript_Shorten_Function-1up>

------
chrisbroadfoot
Two things:

1) Gb should be GiB

2) it would be lovely to see some internationalisation support.

------
chris_wot
This might need some internationalization support...

~~~
alastairpat
pferreir, just a heads-up - you've been hellbanned. This means all of your
comments are automatically marked as [dead], but you can't see this.

~~~
alastairpat
You'll probably need to start a new account, unfortunately – there doesn't
appear to be any protocol for being 'unhellbanned'.

~~~
alastairpat
I'm just the messenger – by no means am I in any way associated with HN.

------
mahmud
All of them are built into Play Framework, fwiw.

