ScarletsFiction / ScarletsFrame

A frontend framework that can help you write performant complex web feature with low dev time and resource cost.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add range feature for sf-each

StefansArya opened this issue · comments

Currently sf-each was supported to be used with Array, Object, Map, and Set.
The minimal example of the template is like below.

<ex-ample>
  <div sf-each="val in target"> {{ val }} </div>
</ex-ample>

<script>
  sf.component('ex-ample', function(My){
    My.target = [2, 4, 6];
  });
</script>

And the result would be like this:

<div> 2 </div>
<div> 4 </div>
<div> 6 </div>

To make it more easier (so we don't need to create an array).
I'm going to add feature like range.

<ex-ample>
  <div sf-each="val in range(begin, end, increment)"> {{ val }} </div>
</ex-ample>

<script>
  sf.component('ex-ample', function(My){
    My.begin = 2;
    My.end = 6;
    My.increment = 2;
  });
</script>

Modifying the value of My.increment will also refresh the elements.
Does anybody have a comment or suggestion before I added the range feature?

Feel free if you also want to do a pull request to add this feature 😄

This feature has been implemented for v0.34, you can use it just like my comment above.