
New Official jQuery Plugins Provide Templating, Data Linking and Globalization - johns
http://blog.jquery.com/2010/10/04/new-official-jquery-plugins-provide-templating-data-linking-and-globalization/
======
billybob
Notably, contributed by Microsoft.

I... I have nothing bad to say about that.

Hmmm.

~~~
WesleyJohnson
I was kind of surprised by this. Has Microsoft done this before (contributed
to an Open Source project not of their own making) or is this new for them?

~~~
contextfree
IIRC they've contributed a few bits and pieces to Apache and the Linux kernel
(drivers), though I think they've just been for interop with other MSFT stuff.

------
Griever
This is interesting. Just the other day I saw a flash ad on Reddit touting all
the new features in Visual Studio 2010. I was surprised to see that one of the
slides mentioned "Support for including the jQuery Framework".

Glad to see that riding the jQuery train rather than making their own or
something along those lines.

~~~
evo_9
No kidding, now if MS would just give up the whole Silverlight waste of time
(no we do not need _another_ flash-like proprietary format).

~~~
pufuwozu
Microsoft is supporting the development of Moonlight (an open-source
implementation). The only part that Microsoft won't license is DRM.

It can't be compared Flash - Adobe has shown NO interest in helping open-
source implementations.

~~~
evo_9
Irregardless of MS's support of Moonlight, I question the entire effort.
Wouldn't those talented programmer be put to better use on something with a
higher chance of actually being used?

I actually really dig mono and in my mind those resources would serve the
community better focused on Mono, MonoDevelop, MonoTouch and MonoDroid.

I just don't see wide-scale adoption of Silverlight/Moonlight whether it's
available on *nix or not, with or with MS's blessing.

~~~
pufuwozu
Moonlight isn't useless.

There was a goal (a while back) of getting Moonlight embedded in Firefox (on
all platforms). The goal hasn't come true but think about that. A general
purpose VM embedded right in the browser!

I have no doubt that Moonlight would be used if it was embedded within the
browser. CIL is an open-specification, we already have many compilers that
target it. We could run C#, Scala, Java, Python, Ruby, Haskell, etc on the
client side.

But all we're stuck with is a JavaScript VM to use.

~~~
evo_9
I think the fact that this thread has only the two of us interested sums of
the interest in Silverlight/Moonlight in the hacker community. ;)

I guess I wonder why I would want to write C#, Scala, etc on the clientside?
Javascript is an already established cross-browser standard that I'd say any
good developer is already familiar with; certainly jQuery strengthens the case
for JS and also is bringing more people into the fold.

And with Node.js - which clearly has a lot of interest in the HN community
(node.js stories always get upvoted as well they should) - it seems that
things are moving in the opposite direction from what moonlight/ms is trying
to accomplish with this particular tech.

For all those reasons it just seems like a fools errand to me.

------
pornel
I'm disappointed that template syntax uses own {{if}} tags:

    
    
        {{if cond}}<li>...</li>{{/if}}
    

TAL and Genshi have IMHO much nicer solution for that:

    
    
        <li py:if="cond">...</li>
    

Use of attributes on existing elements also ensures that you can't create ill-
formed structures like {{if}}<li>{{/if}}</li>.

~~~
jeresig
We opted not to use this particular technique for two reasons: 1) It's not
nearly as versatile. You can use the if statements on elements, attributes,
text - anything you wish - there is no restriction on its contents or
location. 2) In order to actually use something like that we'd have to
serialize the DOM tree first, traverse it, and then manipulate the nodes into
the proper shape. This is _slow slow slow_ and absolutely must be avoided at
any cost.

~~~
detst
A little off topic but I expect this to go well with jQuery Mobile. Can we
expect any updates there? Been a bit disappointed by the relative quiet since
the announcement (not that you owe me anything). Also, is there any publicly
available code to check out? Thanks!

~~~
jeresig
Only quiet because we're working so hard. We're releasing the alpha on October
16th (at the jQuery conference in Boston) so we're a bit frantic at the
moment. Either way we're hoping to get a blog post up this week.

~~~
detst
Thanks, I'm looking forward to it and trying to be patient.

------
yatsyk
I'm little confused: Yehuda Katz who is a member of jQuery team announced
Handlebars.js (templating engine with similar syntax) less then month ago...

Would someone clarify differences between these libraries?

~~~
jeresig
The jQuery project has been working on this this particular plugin for a while
now. Based upon what Yehuda wrote up in his original Handlebars.js blog post:
<http://yehudakatz.com/2010/09/09/announcing-handlebars-js/>

He also recommends the official jQuery templating plugin. As is the case with
most templating plugins there are minor syntax differences - although it does
appear as the two plugins tackle the underlying problem in very similar
manners (leading to fast execution time). I've pinged Yehuda so that he can
comment here, as well.

~~~
yatsyk
John, thank you for clarification!

------
andreyf
Yuk. Why does it introduce a new global namespace for "named templates"? In
other words, why:

    
    
        $.template("foo", ...);
    

When what I mean is:

    
    
        foo = $.template(...);

------
ARolek
Data binding! Finally. That is one of my favorite features of the Flex
framework. I remember reading about Microsoft working on this with jQuery, but
never knew when to expect it. Great news.

------
eclark
The Globalization sounds like a good idea. However the template library scares
me. There are so many different template use cases in JS that having one
ordained jquery one seems like it might have to be too many things to too many
people.

~~~
dstein
JavaScript templating may sound scary, but if done properly they can be so
ridiculously powerful that at this point I think it's inevitable that server-
side generation of HTML will eventually be obsolete.

Imagine being able to throw away all the hideous and incompatible JSP, eRuby,
PHP (smarty etc), and Django templates with a universal template language.

~~~
pornel
Technically there's nothing preventing universal server-side templating
language (e.g. XSLT & TAL are available for all languages you've mentioned).
It's just a matter of everyone agreeing on syntax — and that's the hard part.

~~~
andrewvc
You can't just agree on syntax, IMHO the reason for that is the best template
languages have the full language available. You need a full-language for a
great template language. Smarty, for instance, sucks. HAML, which is terse,
but has access to the full syntax of ruby rocks. You can do things like:

    
    
      = @users.map {|u| sprintf("%04d: %s",u.id, u.status.capitalize)}.join(', ')
    

Sure there's some special operator is smarty to do this, but I don't want to
have to learn it, and they're always more clunky.

Additionally, I always hit complex, weird situations where I need a full-
language, and migrating that logic out of the view makes no sense. For
instance, I was working on a site where I had repeating content, with ads at
predetermined offsets. I rendered it something like:

    
    
      ads_positions = Set.new(2,8,10,12)
      content.each_with_index do |content,i|
        if ad_positions.include?(i)
          content
          ad
        else
          content
        end
      end
    

I hate expressing that stuff server-side or in half-baked templating
languages.

------
chunkyslink
How does using javascript templating effect the SEO of my pages?

If I'm pulling the content in as json and using jquery to place it on the
page. Will Google understand this or see my pages as content-less?

~~~
WesleyJohnson
Yes, if you load in all your content through AJAX/AJAH or some other form of
client side process, google won't get that content when crawling your page.
The best way to see what search engines will see is to load the page in a
browser and then use "View Source".

There are ways to help search engines find your dynamic content, however,
which typically involve creating static versions of the content in addition to
your more user-friendly AJAX versions. Google outlines some methods for doing
this using specially formatted hash tags here:
<http://code.google.com/web/ajaxcrawling/index.html>

------
Groxx
Interesting technique... I wonder how long until someone sets up a Haml clone
in a similar vein, however. Less[1] is already moving in that direction, the
next step is to do HTML in a similarly-friendly way. I'd use _that_ ; this is
a pretty hideous, clearly-MS-influenced Enterprisey implementation.

[1]: <http://lesscss.org/>

