FOR loop related

18 views
Skip to first unread message

Kane Sun

unread,
Aug 15, 2013, 1:07:50 PM8/15/13
to rapt...@googlegroups.com

I have a question regarding for loop in raptor template. The examples of “for” loop only show how to loop an array.

Do we have a way to loop based on length? Like Java does for(int i=0; i<length; i++)

Phil Gates-Idem

unread,
Aug 15, 2013, 1:16:29 PM8/15/13
to rapt...@googlegroups.com
Kane,
As far as I know, this is not supported using the special "for"-loop construct in Raptor, however, you can break out into raw JavaScript using code like this in your template:
{%
for (var i = 0; i &lt; 10; i++) {
%}
    Hello
{%
}
%}

This should print out "Hello" 10 times.

Let me know if that doesn't work for you.

Thanks,
Phil
Reply all
Reply to author
Forward
0 new messages