W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2013

Re: E4H and constructing DOMs

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Tue, 12 Mar 2013 03:22:14 +0100
To: Ian Hickson <ian@hixie.ch>
Cc: <public-script-coord@w3.org>
Message-ID: <uk3tj8lr5qgnmiua29uqb283oo3rb0gr79@hive.bjoern.hoehrmann.de>
* Ian Hickson wrote:
>E4H's design goals were:
>
> - to provide compile-time syntax checking for in-script DOM tree creation
> - to provide in-script DOM tree creation in a terse and intuitive fashion
> - to provide syntactic sugar for the most common use cases for in-script 
>   DOM tree creation, specifically:
>    * inserting strings into attribute values
>    * inserting strings into element contents
>    * setting HTML boolean attributes conditionally based on an expression

It seems to me that a critical feature here is to be able to have actual
Nodes as template parameters, so can do something akin to

  var parsedHTML = parseHTML("...", { ... }); // a DocumentFragment
  ...
  ... <div>${ parsedHTML }</div> ...
  ...

and my understanding is that both E4H and ES6 templates, as proposed, do
allow for that; (a simple example of where you would want this is when
you dynamically retrieve a HTML fragment with some formatting elements
from the server and want to enclose it in some other element structure).

A related feature is being able to retrieve a template "string" from the
server and dynamically fill it in in the browser. E4H does not seem to
support that without using eval() while ES6 templates might support it,
but I have yet to check that.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Tuesday, 12 March 2013 02:22:42 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:09 UTC