fabpot/Twig — pull request #614 by Tobion (2012-01-26 01:36:07+00:00)
Title: Made the random function more versatile

The point is to meet user expectations and to make it more versatile, so it works under more circumstances.
At the moment the random function does only return the supplied parameter when it's not an array. That is not very usefull. With this PR it will behave like

random() => integer as with mt_rand()
random(5) => integer between 0 and 5 as with mt_rand(0, 5)
random('foobar') => random character from 'foobar'
random(array(...)) => random element

I will add tests and documentation if you accept this PR.