Alien-GvaScript

 view release on metacpan or  search on metacpan

doc/html/Repeat.html  view on Meta::CPAN

(<a href="http://www.whatwg.org/specs/web-forms/current-work/">http://www.whatwg.org/specs/web-forms/current-work/</a>), but is 
not an attempt to implement the proposed specification: there are
some differences both in syntax and in semantics.</p>
  <div class="TN_node" id="Terminology">
    <h3 class="TN_label">Terminology</h3>
    <div class="TN_content">
      <p>At initialization stage, the DOM is inspected for finding
<i>repeat elements</i> (elements having a <code>repeat</code> attribute).
These elements are removed from the DOM and replaced
by <i>placeholders</i> (empty DOM elements, just marking where
the repetition blocks should be inserted).
Each placeholder stores a <i>template</i>, which is 
a plain string representation of the repeat element, with 
special markup for template instanciation. 
The template may then be dynamically instanciated into
<i>repetition blocks</i> by calling the <a href="#add">/add</a> method.</p>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="HTML">
    <h2 class="TN_label">HTML</h2>
    <div class="TN_content">
        <div class="TN_node" id="Markup_of_repeat_elements">
    <h3 class="TN_label">Markup of repeat elements</h3>
    <div class="TN_content">
      <pre>  &lt;div repeat="foo" repeat-start="3" repeat-min="2" repeat-max="6" 
                    repeat-prefix=""&gt;
    &lt;!-- content to be repeated, using #{foo.ix}, #{foo.path}, etc. --&gt;
  &lt;/div&gt;</pre>

<p>Any element marked with a non-empty <code>repeat</code> attribute is
a <i>repeat element</i>; the value of that attribute defines
the <i>repeat name</i>. Repeat elements can be nested, and their
repeat names are used to distinguish at which level a repetition
block should be instanciated.</p>
<p>Other attributes of the repetion model all start with 
the <code>repeat</code> prefix, as listed below; these attributes are optional.</p>
<ul>
<li><a name="item_repeat"></a><b>repeat</b>
<p>marks the element as a repeat element, and defines the repeat name.</p>
</li>
<li><a name="item_repeat_start"></a><b>repeat-start</b>
<p>defines how many repetition blocks should be automatically
created as initialization time. Default is 1.</p>
</li>
<li><a name="item_repeat_min"></a><b>repeat-min</b>
<p>minimum number of repetition blocks. Prevents deletion
of repetition blocks under that number. Default is 0.</p>
</li>
<li><a name="item_repeat_max"></a><b>repeat-max</b>
<p>maximum number of repetition blocks. Prevents addition
of repetition blocks over that number. Default is 99.</p>
</li>
<li><a name="item_repeat_prefix"></a><b>repeat-prefix</b>
<p>defines the initial fragment of the <code>repeat path</code> (see 
explanation below). Only valid for top-level repetition elements, 
because nested repetition elements are automatically prefixed
by their parent repetition element. Default is the empty string.</p>
</li>
</ul>

    </div>
  </div>
  <div class="TN_node" id="String_substitutions_within_repeat_elements">
    <h3 class="TN_label">String substitutions within repeat elements</h3>
    <div class="TN_content">
      <p>The content of a repeat element may contain special markup
for repetition variables, which will be replaced by values
when the element is instanciated into a repetition block.</p>
<p>Variables are written <code>#{&lt;repetition name&gt;.&lt;variable&gt;}</code>, like for
example <code>#{foo.ix}</code>, <code>#{foo.count}</code> or <code>#{bar.path}</code>. The
repetition name is the value of the <code>repeat</code> attribute of the repeat
element, as explained above; in this namespace, the following
variables are defined</p>
<ul>
<li><a name="item_count"></a><b>count</b>
<p>current number of repetition blocks for that repeat element, starting at 1.</p>
</li>
<li><a name="item_ix"></a><b>ix</b>
<p>integer index of the current repetition block, starting at 0.</p>
</li>
<li><a name="item_path"></a><b>path</b>
<p>cumulated list of repetition name and repetition indices, separated
by dots.</p>
</li>
<li><a name="item_min"></a><b>min</b>
<p>value of the <code>repeat-min</code> attribute.</p>
</li>
<li><a name="item_max"></a><b>max</b>
<p>value of the <code>repeat-max</code> attribute.</p>
</li>
</ul>
<p>The <code>path</code> is unique within any nesting of repeat elements,
and therefore is typically used for ids or for
names of input elements :</p>
<pre>  &lt;tr repeat="bar"&gt;
    &lt;td&gt;Item #{bar.count}&lt;/td&gt;
    &lt;td&gt;&lt;input name="#{bar.path}.buz"&gt;&lt;/td&gt;
  &lt;/tr&gt;</pre>

<p>Within the 3rd repetition block of <code>bar</code>, nested
within the 2nd repetition block of <code>foo</code>, the value of
<code>#{bar.path}</code> will be <code>foo.2.bar.3</code> and therefore
in this example the input name would be
<code>foo.2.bar.3.buz</code>.</p>
<p><i>Implementation note</i>: the <code>#{...}</code> syntax for
variables is borrowed from <code>prototype.js</code>'s <code>Template</code>
class; however, the implementation of substitutions
is done in plain javascript, without calling
<code>Template.evaluate()</code> method.</p>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="METHODS">
    <h2 class="TN_label">METHODS</h2>



( run in 1.140 second using v1.01-cache-2.11-cpan-02777c243ea )