random

The random function returns a random value depending on the supplied parameter type.

Get a random value from an array

{{ random(['bike', 'train', 'car']) }}

Get a random letter from a string

{{ random('ZYX') }}

Get a random number between 0 and 2,147,483,647

{{ random() }}

Get a random number between 0 and 5

{{ random(5) }}

Arguments

The random function has the following signature.

random(values)

Argument Description
values

The thing to get a random value from. 

If value is an array or hash then a random value from the array or hash will be returned.

If value is a string then a random letter from the string will be returned.

If value is a number then a number between 0 and value (including 0 and value) will be returned. If value is positive then a positive number will be returned. If value is negative then a negative number or 0 will be returned.

If no value is passed then a random number between 0 (including 0) and 2,147,483,647 will be returned.

< Back to the list of functions