0 votes
by (710 points)

I tried the following, but it did not work due to syntax reasons.

<<repeat random(2,5)s>>
<<print "test">>


1 Answer

+1 vote
by (159k points)
selected by
Best answer

As explained by the <<repeat>> macro's documentation the first argument needs to be a valid CSS time unit.

NOTE: The delay that the <<repeat>> macro will use is determined at the time that it is called, using random() will not cause that delay to vary for each looping.

There are a number of ways to solve your syntax issue, two of them being:

1. Use a (temporary) variable to store a String representation of the unit you want to randomly determine.

<<set _delay to random(2,5) + 's'>>
<<repeat _delay>>

2. Pass the argument as an expression using back-quotes.

<<repeat `random(2,5) + 's'`>>
	Hi there!