diff options
| author | Aaron Bohy <aab@odoo.com> | 2019-06-07 07:05:05 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-06-26 10:50:26 +0000 |
| commit | a798daa4e7d72780a1feb53453528ef30166324b (patch) | |
| tree | 110baf20b66021c589e754c34505a8d3d2f735c2 /doc | |
| parent | 02e6a8bdb801b7de862689d465dcc6174a287456 (diff) | |
[DOC] qweb: t-foreach: deprecate x_(all|parity|even|odd)
These variables aren't used in Odoo and can be easily computed
anyway.
Also deprecate the support of integer values for t-foreach, for the
same reason.
closes odoo/odoo#33981
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/reference/qweb.rst | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/doc/reference/qweb.rst b/doc/reference/qweb.rst index 2954d0bf167..a4a5b3769a4 100644 --- a/doc/reference/qweb.rst +++ b/doc/reference/qweb.rst @@ -136,16 +136,16 @@ attribute, and is equivalent to the previous example. ``foreach`` can iterate on an array (the current item will be the current -value), a mapping (the current item will be the current key) or an integer -(equivalent to iterating on an array between 0 inclusive and the provided -integer exclusive). +value) or a mapping (the current item will be the current key). Iterating on an +integer (equivalent to iterating on an array between 0 inclusive and the +provided integer exclusive) is still supported but deprecated. In addition to the name passed via ``t-as``, ``foreach`` provides a few other variables for various data points: .. warning:: ``$as`` will be replaced by the name passed to ``t-as`` -:samp:`{$as}_all` +:samp:`{$as}_all` (deprecated) the object being iterated over .. note:: This variable is only available on JavaScript QWeb, not Python. @@ -164,16 +164,15 @@ variables for various data points: whether the current item is the last of the iteration (equivalent to :samp:`{$as}_index + 1 == {$as}_size`), requires the iteratee's size be available -:samp:`{$as}_parity` +:samp:`{$as}_parity` (deprecated) either ``"even"`` or ``"odd"``, the parity of the current iteration round -:samp:`{$as}_even` +:samp:`{$as}_even` (deprecated) a boolean flag indicating that the current iteration round is on an even index -:samp:`{$as}_odd` +:samp:`{$as}_odd` (deprecated) a boolean flag indicating that the current iteration round is on an odd index - These extra variables provided and all new variables created into the ``foreach`` are only available in the scope of the``foreach``. If the variable exists outside the context of the ``foreach``, the value is copied @@ -217,7 +216,9 @@ exists in 3 different forms: string (e.g. classes):: <t t-foreach="[1, 2, 3]" t-as="item"> - <li t-attf-class="row {{ item_parity }}"><t t-esc="item"/></li> + <li t-attf-class="row {{ (item_index % 2 === 0) ? 'even' : 'odd' }}"> + <t t-esc="item"/> + </li> </t> will be rendered as:: |
