how to add for loop with spark view engine

737 Views Asked by At

Is there a way to add a for loop when using spark view engine ? I'm trying to add pagination support to my view and trying to loop through and add list entries listed below:

<li><a href="#">1</a></li>
<li><a href="#">2</a></li>

Unfortunately all I can find are examples to use foreach. Is there way to do this in spark ?

2

There are 2 best solutions below

0
On BEST ANSWER

No direct way, but several indirect methods are listed in this page:

https://groups.google.com/forum/#!searchin/spark-dev/for$20loop/spark-dev/vfUUg2KUFk4/yqJ4iRUNYC4J

0
On

I guess the only thing a for loop would give you over a foreach is the index of the current item (well, that and obviously being able to control the size of iteration increments), but in Spark we provide the index of the current item so that you can use it like this:

<for each="var thingy in Model.Thingies">
  <div>Item ${thingyIndex} of ${thingyCount}</div>
</for>