- From: Robin Berjon <robin@w3.org>
- Date: Mon, 03 Jun 2013 21:59:02 +0200
- To: "Henry S. Thompson" <ht@inf.ed.ac.uk>
- CC: spec-prod@frink.w3.org
On 03/06/2013 19:44 , Henry S. Thompson wrote: > Robin Berjon writes: >> Note that this does *not* prevent you from creating your documents as >> XHTML, editing them with XML tools, etc. It's only a problem if they >> then get served as such. Is that an issue? > > But, as you put it in the intro to the doc't, being able to see what > you've done simply by refreshing the browser is the whole point. > Works with xml+xmlspec+XSLT-in-the-browser, works with respec+HTML5, > . . . Oh well. At no point do I claim that you can't do the same thing with XSLT. Before ReSpec was written in JS, it was precisely a mixture of Perl and XSLT. As someone who can code in both, I find using JS a *lot* easier, though. And I prefer using ReSpec's current simple document syntax over anything else I've tried. But that's just me, I'm not making you use it if you prefer XMLSpec :) > It does intrigue me to try to understand _why_ PHP-style coding is so > attractive that we do it even when good structure-based alternatives > are right there in the API, especially given that string bashing to > build structure is > a) fragile; > b) hard to read; > c) hard to debug; > and I presume > d) less efficient. I think that the fact that you conflate this with PHP-style coding is indicative that you don't actually know how it works. Mixing markup and conditionals is almost always painful, only XQuery approaches doing it well (XSLT doesn't). But XQuery is not available so that's ruled out. The second best thing to use for things that involve complex markup with interpolated values and conditionals is a templating language. The DOM is just maddening of anything beyond a few simple manipulations. That's what we have here. It uses something called Handlebars, which isn't particularly good (unless you think that so-called logicless templating is a feature — I absolutely don't), but is particularly simple and well-known by developers. This makes it easy to build, easy to read, reasonably resilient, pretty easy to debug, and acceptably fast (I have some plans to make it even faster by precompiling the templates, but that's low priority). That gives us some HTML. The HTML is then assigned as a subtree of a larger tree (using innerHTML). I'd certainly be very interested in hearing about better options. I've tried a *lot* of options, so far these are those I consider best (I'd use doT instead of Handlebars if I wrote it today, but that's a minor consideration). -- Robin Berjon - http://berjon.com/ - @robinberjon
Received on Monday, 3 June 2013 19:59:18 UTC