-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Here is the specification: https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#226-list
"
- Iterates over the content of each item in the attribute value, allowing to control the iteration through the following options:
- begin - iteration begins at the item located at the specified index; first item of the collection has index 0
- step - iteration will only process every step items of the collection, starting with the first one
- end - iteration ends at the item located at the specified index (inclusive)
- Element: shown only if the number of items from the attribute value is greater than 0, or if the attribute value is a string or number; when the begin value is used the element will be shown only if the begin value is smaller than the collection's size.
"
Expected Behaviour
I should be able to use data-sly-list for just one element even though it is the first item of a list.
Actual Behaviour
I can use data-sly-list for just one element as long as it is not the first element of a list because the "end" option cannot be "0". This is not stated in the specification but it can be seen in the compiled code:
boolean var_validstartstepend16 = (((org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator.lt(var_begin13, var_size11)) && ((!(org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator.lt(var_begin13, 0))) && true)) && (!(org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator.leq(var_end15, 0))));
Reproduce Scenario (including but not limited to)
Steps to Reproduce
Just write the following code in any valid htl file.
<p>The following test is OK and it should print "2"</p>
<ul data-sly-list="${[1, 2, 3] @ begin = 1, end = 1}">
<li>${item}</li>
</ul>
<p>The following test is not OK and it should print "1" but it does not print the list because the "end" option cannot be "0"</p>
<ul data-sly-list="${[1, 2, 3] @ begin = 0, end = 0}">
<li>${item}</li>
</ul>
Example:
- Download the latest SDK and install the Core Components project
- Go to http://localhost:4502/crx/de/index.jsp#/apps/core/wcm/components/text/v2/text/text.html
- Add the above code
- Go to http://localhost:4502/editor.html/content/core-components-examples/library/core-content/text.html and you should be able to see the test results.
Platform and Version
Any (Cloud and 6.5 for example).
Sample Code that illustrates the problem
<p>The following test is OK and it should print "2"</p>
<ul data-sly-list="${[1, 2, 3] @ begin = 1, end = 1}">
<li>${item}</li>
</ul>
<p>The following test is not OK and it should print "1" but it does not print the list because the "end" option cannot be "0"</p>
<ul data-sly-list="${[1, 2, 3] @ begin = 0, end = 0}">
<li>${item}</li>
</ul>
Logs taken while reproducing problem
No logs needed