Re: [webcomponents] HTML Parsing and the <template> element

On Wed, Feb 8, 2012 at 2:54 PM, Dimitri Glazkov <dglazkov@chromium.org>wrote:

> On Wed, Feb 8, 2012 at 2:41 PM, Ryosuke Niwa <rniwa@webkit.org> wrote:
> > On Wed, Feb 8, 2012 at 2:00 PM, Dimitri Glazkov <dglazkov@chromium.org>
> > wrote:
> >>
> >> == IDEA 1: Keep template contents parsing in the tokenizer ==
> >>
> >> PRO: if we could come up with a way to perceive the stuff between
> >> <template> and </template> as a character stream, we enable a set of
> >> use cases where the template contents does not need to be a complete
> >> HTML subtree. For example, I could define a template that sets up a
> >> start of a table, then a few that provide repetition patterns for
> >> rows/cells, and then one to close out a table:
> >>
> >> <template id="head"><table><caption>Nyan-nyan</caption><thead> ...
> >> <tbody></template>
> >> <template id="row"><tr><template><td> ...
> </td></template></tr></template>
> >> <template id="foot"></tbody></table></template>
> >>
> >> Then I could slam these templates together with some API and produce
> >> an arbitrary set of tables.
> >
> >
> > But that could be done in the second approach as well, right? All you
> need
> > to do is replace "..." by <span class="placeholder"></span> and you can
> > replace that element later by some API.
>
> I am not sure I understand what you're saying here, so I'll try to
> clarify the example. The first and last templates contain incomplete
> tag structures (or partial trees as I call them later--not sure what
> the term is): the first only contains the opening <table> and <tbody>
> tags, and the last one closes them.


Oh, I see what you're saying. But if the authors really wanted to do that,
they can just use script element, right? Of course they can't nest-script
elements but nesting templates that have unpaired tags doesn't sound like a
common use case. Also, if we're supporting nested templates, it's much more
natural to do:
<template id="table">
<table>
<template id="head">
<caption>Nyan-nyan</caption>
<thead>...
</thead>
</template>
<template id="row">
<tbody>
<tr><template><td>...</td></template></tr>
</tbody>
</template>
</table>
</template>

- Ryosuke

Received on Wednesday, 8 February 2012 23:12:49 UTC