New Official jQuery Plugins Provide Templating, Data Linking and Globalization
blog.jquery.com
blog.jquery.com
I... I have nothing bad to say about that.
Hmmm.
I'm hoping not. They've been getting more open-sourcey in the last couple years. One alternative is that they just saw a great model and have no need to reinvent the wheel. It means an easier .net onramp for developers who already know jQuery.
Glad to see that riding the jQuery train rather than making their own or something along those lines.
It can't be compared Flash - Adobe has shown NO interest in helping open-source implementations.
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.
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.
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.
{{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>.I see reason 1. as a downside — it allows very messy Smarty-like markup that can generate ill-formed HTML.
2. I think there's little difference whether you serialize first or later. Are all those new fancy DOM traversal, XPath and XSLT APIs really not faster than parsing and joining of strings?
It cannot be understated how much slower touching the DOM is compared to doing string manipulation. Any DOM touching - but generating DOM nodes and traversing them is radically slow. If you want to support Internet Explorer it's not even an option, as far as performance goes.
Would someone clarify differences between these libraries?
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.
$.template("foo", ...);
When what I mean is: foo = $.template(...);Imagine being able to throw away all the hideous and incompatible JSP, eRuby, PHP (smarty etc), and Django templates with a universal template language.
http://yehudakatz.com/2010/09/09/announcing-handlebars-js/ http://code.google.com/p/trimpath/wiki/JavaScriptTemplates http://code.google.com/p/jstal/ http://github.com/janl/mustache.js
= @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.Having options is a good thing, and I worry that jQuery with it's dominate position could become the defacto standard even if it is not the best choice for all projects.
I've definitely enjoyed a few though, Django's being one of them.
I think Javascript templating is great, and it's certainly helpful in many ways, but it could never flat-out replace server-side template engines for me. In Django for example, you almost always pass whole ORM objects to the template. On someone's page of a list of friends, I'd loop through a collection of User objects and generate an html list of usernames and permalinks to their profile pages. If I passed the whole collection of User objects to the client they'd get access to a lot of sensitive information. Which would require me to white-list at the ORM level exactly what fields I might need ahead of time. That might work, but I'd always be worried that I didn't clean the objects sent to the client's JS template enough for every page I'm writing.
Unless of course you were going for the idea that we'll be using one universal templating language both for the front-end JS as well as on the back-end in something like node. In which case disregard everything I just wrote.
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?
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
[1]: http://lesscss.org/