adobe / adobe/htl-spec

Data-sly-list specification does not accept its "end" option to be "0" even though it is a correct index

Open
#102 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
288
Forks
142
PR merge metrics
No merged PRs in 30d

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.

```

The following test is OK and it should print "2"



  • ${item}


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"



  • ${item}


```

Example:

1. Download the latest SDK and install the Core Components project
2. Go to http://localhost:4502/crx/de/index.jsp#/apps/core/wcm/components/text/v2/text/text.html
3. Add the above code
4. 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

```

The following test is OK and it should print "2"



  • ${item}


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"



  • ${item}


```

#### Logs taken while reproducing problem

No logs needed

Contributor guide

Open the contributing guide

Research direction

Start with the `data-sly-list` section in `SPECIFICATION.md` and compare its stated inclusive `end` behavior with the provided `begin = 0, end = 0` reproduction. Determine whether the specification needs clarification or correction so the documented behavior and example agree; done when the handling of an end index of 0 is explicitly consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.