[whatwg] repetition model

On Fri, 25 Jun 2004, Avi Bryant wrote:
>>
>> I do agree that the [id] stuff is somewhat dodgy. I really am at a loss of
>> how to do a better solution, though. And it does work quite well.
>
> In other words: it's a useful hack.  No argument there, as long as we
> agree that it would be nice to find something that *isn't* dodgy.

If we can find something better, yes.


>>> Effectively you're upping the meta level:  parts of the document are
>>> no longer HTML, but a description of how to produce HTML.
>>
>> HTML4 already has this (<object declare>).
>
> That's similar to having a a template without [id], but it doesn't set a
> precedent for macro expansion at all.

Agreed.


> <object declare> still treats the DOM as a semantic tree rather than as
> bits of text to be manipulated byte by byte, as the repetition model
> does.  That's the part I find offensive. (Though at least the semantic
> rape is confined to attribute values).

Hyperbole aside, it's not that bad -- the tree is still a tree, the
attributes are still attributes containing Unicode characters, etc. And
the entire tree is marked as being a template, so the semantics are right
there. I really don't think it's as bad (semantically) as you suggest.


>> I agree that the []-prefix hack is a hack. Do you have a better solution?
>
> My point is that the [id] hack necessarily begets other hacks, which is
> just further evidence of its hackishness.  The only better solution is
> to get rid of [id].

Other hacks? There are exactly two hacks. The search for [id], and the
initial [] to prevent the search for [id].



> something like this (simplified):
>
> <div>
> <input name="customer" value="cust1">
> <input name="account" value="account1">
> <input name="account" value="account2">
> </div>
>
> <div>
> <input name="customer" value="cust2">
> <input name="account" value="account3">
> </div>
>
> And on the server you'd have
>
> customer=[cust1,cust2]
> account=[account1, account2, account3]
>
> with no way to tell which accounts went with which customers.

That's one problem; the other problem is:

 <div>
 <input name="comment" value="comment1-1">
 <input name="comment" value="comment1-2">
 </div>

 <div>
 <input name="comment" value="comment2-1">
 </div>


> For people with CGI libs like that, one easy workaround would be this:
> after each set of repeats of a template, insert hidden fields with the
> same name as each input and and "end of group" marker value.

How do you distinguish the "end of group" marker from an actual value?
This is at least as much of a hack as the [] thing.


>> This is especially important with nested repeats, where
>> the "add" button has to refer to a template that has been repeated.
>> Templates are identified by IDs, so you need a unique ID for each
>> repeated template. (There's an example of this in the spec.)
>
> If buttons referred to templates by name instead of ID, this wouldn't be a
> problem - they would just be hooked up to the closest template of the
> right name (and I'm pretty sure we could find a suitable definition of
> "close").

I'm not at all convinced that would be much better. :-)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 25 June 2004 13:58:44 UTC