--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en.
Hi
I lurk in this group, and your post interested me, because I care about templating.
I had a look at your code at
http://github.com/pure/pure/blob/master/js/pure.js
and spotted
return typeof obj.length === 'number' && !(obj.propertyIsEnumerable('length')) && typeof obj.splice === 'function';},
which seems to be testing obj for being an array. (BTW, the display in my browser of this pages is messed up - the lines are truncated left and right.)
The best way, I think, to test for an array is to use what is known as the Miller Device:
$ js
js> Object.prototype.toString.call({})
[object Object]
js> Object.prototype.toString.call([])
[object Array]
js>
I'd like to see a little library of functions such as isArray() (or is_array()) that people such as yourself can consult and use.
I was wondering if HTML templating is of any interest here.
I've seen some old posts about it.
I'm the author of PURE, a fast and unobtrusive HTML/JSON rendering
engine.
The 2nd version was totally rewritten in functional JS and do not use
eval anymore.
Although it was primarily designed to run client side, Davey Waterson
from Aptana made it work with Jaxer (out of the box).
And Phil Harnish from Youtube made it to work on Rhino (not that out
of the box).
It is a very different approach from the <%...%> templating engines
alike, and keep a strong separation between the HTML and the JS.
--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
I read your link about requirements for a modern web dev framework, Mário. Are you suggesting that every page that loads should use JS to contact a server, retrieve a JSON object, and then do the databinding in the browser? This seems like a bad arrangement for those of us concerned about load-time of pages. Loading even the simplest of pages would then require 2 server round-trips. Am I misunderstanding?
-- MV
Hi Francisco,
I'm on the same extreme views as Mario to generate everything on the
client.
PURE came from this need and have it as fast as XSLT/XML client side
but for JSON.
For me here are the reasons:
- offload all the rendering work from the server to the client
- reduce the network traffic: the data is always smaller than its HTML
representation
- except JSON data, all your app end up in the cache and reduce even
more the network load
- as HTML, JS, CSS are kind of inevitable today why put an additional
server technology to learn and maintain
And finally the 2 reasons I find useful to generate server pages are:
- SEO, this is a killer, but as we are building a web app, it's not a
concern
- generate pdf, csv, or HTML table based data to something else than a
browser.
Agree w/ you Kris. A solution that supports both runtime and 'compile
time' templating is the holy grail. Think, for example, of this
typical snippet of whatever code:
<% if (person.isSignedIn()) { %>
Welcome back Fred.
<% } else { %>
<a href="/signin">Sign in</a>
<% } %>
This sort of conditional stuff makes good clean sense for server
processing. The alternative to a pure client solution to this problem
smells like old socks. Maybe I'm wrong?
So, but then you'd have to do something like this right?
<div id="account">
<div id="signedIn"></div>
<div id="signedOut"></div>
</div>
Therefore sending extra extraneous, unrelated, and thus somewhat
un-semantic, markup to the client. Maybe this is solved with fragments
and clientside logic.
Maybe you are thinking along these lines?
<script>
x$('#account').xhr('/person', function() {
var person = eval('(' + this.responseText ')');
if (person) {
// render html fragment in place of the sign in fragment
}
});
</script>
I could be sold on that approach.
I mean, I don't think this is an either/or proposition. Client makes
sense for many if not most templating scenarios but the server can
make very good sense in conditional / stateful scenarios. As the
yogi's say, "Favor balance to purity".
JavaScript should be the vehicle of balance between server and client.
The middle path. Etc.
--
tfreitas--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en.
This is the most interesting advantage IMHO. Generic pages can be served statically and cached for all users, whereas pages with user specific elements will have to be served up individually for each user. With client-side templating, essentially all pages are generic.
<ul id = "titles">
<% while (index--) { %>
<li><%titles[index]%></li>
<% } %>
</ul>
Zach;On Tue, Dec 1, 2009 at 5:49 PM, Zachary Carter <zack....@gmail.com> wrote:
This is the most interesting advantage IMHO. Generic pages can be served statically and cached for all users, whereas pages with user specific elements will have to be served up individually for each user. With client-side templating, essentially all pages are generic.
This is true, but you have to understand a one-size-fits-all solution is almost never right in all cases.
Take the case where the page is a small bit of boiler plate, and a address book. Now imagine that address book is 5000 lines long.
I can VERY easily imagine a case where rending on the client by looping over JSON and poking at the DOM would be a full two orders of magnitude slower on a client running IE6 than looping over a database connection and spitting out HTML on the server.
In this case, the user experience would be much, much better and the server load would not be significantly different (especially if you were running mod_deflate or something).
This type of query is also cacheable, albeit only on a user-by-user basis, so you can't take advantage of centralized caches or CDNs.
Wes
--
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en.
FWIW I would probably render this incrementally on the client, and perhaps even fetch incrementally. So as the user scrolls, the next "page" or so are requested in the background. Basically pagination without the pages, or the "infinite-scroll" trick. I could see this improving performance for slow clients like IE6, for at least the initial page load.