JS Humanizer

Milan Vrekic
C:/Milan
Published in
1 min readApr 15, 2012

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 for TitanFile and thought that others might find it useful too:

JS Humanizer supports:

intcomma (4500000 = 4,500,000)

intword (1000000 = 1.0 million)

naturalDay (15 April 2012 16:25:30 = Today)

ordinal (3 = 3rd)

filesizeformat (1234567890 = 1.15 Gb)

linebreaks (Playning with blank lines = <p>Play<br />ing with blank lines</p>)

linebreaksbr (Playning with blank lines = Play<br />ing with blank lines)

pluralize (1, “y”, “ies” = y)

truncatechars (“hello world”, 10 = “hello w…”)

truncatewords (“Playing with truncate words”, 3 = Playing with truncate …)

--

--

Milan Vrekic
C:/Milan

Product Manager @POF, Volta, Zora & TitanFile co-founder, Maritimer living on the West Coast.