DailyJS

jQuery Roundup: 1.7 Beta 2, Counter, Templator

2011-10-18 00:00:00 +0100 by Alex R. Young
Note: You can send your plugins and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).

jQuery 1.7 Beta 2

jQuery 1.7 Beta 2 is
out. It's worth skimming over the whole change log in the announcement
to check for things that may affect your scripts. This release includes
a lot of IE fixes and improvements, for example:

There are 68 fixes and improvements altogether; 15 are for IE support.

jQuery Word and Character Counter

Counter (License: MIT) by Wilkins Fernandez is a word and character counting plugin that works a little
bit like Twitter. \$(selector).counter(); will add a
character counter to a textarea. It supports lots of
options -- it's possible to enforce the word or character limit by
preventing more text from being entered, or to simply count forever:

// This will simply print the character count forever
$(selector).counter({
  goal: 'sky'
});

$(selector).counter({
  type: 'word'
, goal: 'sky'
});

The thing I've always found challenging about word counting algorithms
is supporting other languages. A naive word count implementation is
likely to get Japanese and Chinese word counts wrong. It would be
interesting to see this supported here (or your favourite JavaScript
algorithm for doing this in the comments).

Templator

Templator (License: AOL) by Nijiko Yonskai is a template manager, and currently supports a wide
range of template languages. It depends on jQuery, and includes support
for mustache.js, jSmart, TrimPath Template, YAJET, and more (look at
Template/lib/ to see what template languages are supported).

It also comes with a caching system:

var Template = new Templator({
    language: 'jSmart', // Supported Languages: jSmart, EJS, Moustache, Trimpath, YAJET, JST, or Empty
    cache: {
        enabled: false,
        life: 32000,
        tick: 1000
    }
});

And has a chainable API:

var Template = new Templator({ language: 'yajet' })
   .storeElement('tmpl', '.tmpl', { foo: 'Hello', bar: 'World!' })
   .partialElement({ partial: '.partial' }, {}, 'tmpl')
   .on('.this')
   .render('tmpl');

It can also be used in a rudimentary fashion without a template
language:

var Template = new Templator({ language: '' });
Template.renderRaw('Hello {name}!', { name: 'World' });