W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2011

Re: Simplifying element creation

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Mon, 14 Nov 2011 16:08:19 -0800
Message-ID: <CABNRm61ZVZpdjVU0cEi2BZ_d5Pjsak2TCR4gCzUqfHpDtVaH-g@mail.gmail.com>
To: Bjoern Hoehrmann <derhoermi@gmx.net>
Cc: Anne van Kesteren <annevk@opera.com>, "www-dom@w3.org" <www-dom@w3.org>
On Mon, Nov 14, 2011 at 3:41 PM, Bjoern Hoehrmann <derhoermi@gmx.net> wrote:
>
> Maybe you are looking for templates, say something like
>
>  <template name='example' white-space='tidy'>
>  <tr>
>    <td>{0}</td>
>    <td>
>      <span class='bar' style='width: {1}%'>
>        <span class='value-container'>{2}</span>
>      </span>
>    </td>
>  </tr>
>  </template>
>  ...
>  var node = fill("example", labels[i], <some expression>, values[i]);
>
> or with named parameters (make some names up), say,
>
>  var node = fill("example", {
>    '0': labels[i],
>    '1': <some expression>,
>    '2': values[i]
>  });
>
> That would seem to suit your use case better.
>

Yeah, template element will be super useful for my use case though it
doesn't address all edge cases because I have to tweak the DOM depending on
the dataset I get.

- Ryosuke
Received on Tuesday, 15 November 2011 00:09:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:08 GMT