

JQuery Blueprint - a js templating framework in just 30 lines of code. - bunchesofdonald
http://github.com/bunchesofdonald/jquery-blueprint

======
echaozh
Have you seen <http://beebole.com/pure/> before?

~~~
bunchesofdonald
I hadn't... but it still looks like it does far more than I want. But it does
look like it might be one step up in functionality, for those who want just a
little more control over the rendering process.

~~~
tchvil
PURE had ~50 lines when starting, but then the real life came with its clunky
browsers, various libs and functionality needs.

------
sarwarb
Have you seen <http://code.google.com/p/trimpath/wiki/JavaScriptTemplates>?

------
tariq
care to elaborate how it compares to other js templating frameworks? (ie.
features, speed)

~~~
bunchesofdonald
As far as features, there aren't many. I'd looked at all the other js
templaters and they all seemed to do too much, IMO. I just wanted one that
would take an html template, let me give it a data object, and have it render
it into an element on the page.

Speed wise, I haven't benchmarked it, but it uses regex (admittedly not the
best way) and jquery.append() to do the heavy-lifting, that combined with the
fact it's doing very little, it should be very fast.

I'm working on making it parse the template first that way I can get rid of
the regex, or at least minimize it's usage.

------
weesilmania
But why?

~~~
weesilmania
Sorry I don't mean to be cheeky, I seriously want to know what the application
of this might be, can't see a real-world example.

~~~
WesleyJohnson
Templating systems are pretty useful and used in quite a few frameworks. Alot
of the controls in ASP.NET basically work as templates where you define the
markup and bind a list of data to the control the markup (template) is
repeated for each piece of data. This is relatively easy on the server side,
but on the client side it's a bit more difficult.

If you wanted to create a realtime twitter client, for example, done all on
the client you'd need to fetch a collection of new tweets periodically and
render them in JavaScript. Without a templating framework, you'd have to loop
through the new tweets and construct the presentation using something like
"innerHTML" or "document.createElement()". A templating system allows you to
construct the layout of a single tweet in standard HTML, mix in a bit of the
template's JS syntax, and then essentially "bind" the list of new tweets to
the template and the markup is repeated for each new tweet.

Given that example, there are plenty of uses that follow the idea of
replicating content over and over using the same template: Email clients, chat
clients, news readers, blogs, photo galleries, classified listings, etc, etc.

~~~
weesilmania
Ah, very useful :) Thanks.

------
xhuang
gist: replace

