[whatwg] Solution to Repetition Model Template Problem

Matthew Raymond mattraymond at earthlink.net
Fri Jun 25 13:58:38 PDT 2004


    As you may already know, there's a serious problem with the current 
repetition system in Web Forms 2.0. The problem is that the template 
always shows up in non-WF2 UAs. You could use CSS to hide the template, 
but then how would you provide styling to blocks generated from the 
template and how would you prevent the template control data from being 
submitted? I have a solution to these problems: Replace the "replace" 
attribute with a <template> element.

    The current model looks like this:

    <tr id="order" repeat="template">
     <td><input type="text" name="row[order].product" value=""></td>
     <td><input type="text" name="row[order].quantity" value="1"></td>
    </tr>

    The solution I propose would look like this:

    <template id="order"><!--
      <tr id="row[order]">
       <td><input type="text" name="row[order].product" value=""></td>
       <td><input type="text" name="row[order].quantity" value="1"></td>
      </tr>
    --></template>

    The <template> element uses the text in the comments to create the 
new block, which I think is really more in keeping with what the 
repetition model is doing anyways. Furthermore, the <template> element 
frees up the "id" attribute so that unique IDs can be assigned to each 
new block.

    Because the contents of <template> are in comments, and because 
undefined elements are ignored in HTML, the template never shows up in a 
non-WF2 UA. Furthermore, since templates are not rendered in WF2, it's 
not visible in a WF2 UA either.

    The repeat attribute would remain unchanged for all non-template 
elements.

    Any thoughts on this?



More information about the whatwg mailing list