Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While attempting to upgrade a Bootstrap Less port to use
each()
(seanCodes/bootstrap-less-port#12), I saw that there were still some gaps for porting Sass to Less code. Specifically, when looping X number of times based on a variable value. (This has been discussed in numerous issues, including as early as #249 and #2270.)This PR fills a major gap by adding a very modest list-generating
range()
function modelled after Lodash / PHP / others. Coupled witheach()
it provides a native replacement for a Sass@for
loop (along with letting you generate range lists for any other general purpose). This solvesfor
loops without the syntactic burden of adding a new paradigm. It simply creates and populates a list in a declarative way.Like Lodash, the function signature is:
range([start=1], end, [step=1])
Start and step are optional (with step requiring a start). Also, this adopts Less behavior of unit casting. That is, the "end" value's unit is applied to the output units. (Also, consistent with Less, lists are 1-based, so unlike Lodash, the default start value is
1
.)Meaning:
Coupled with
each()
, this constructsfor
-style incremental loops.Outputs: