cloudfour / core-hbs-helpers

Handlebars helpers that we usually need
MIT License
11 stars 2 forks source link

Allow random helper to accept multiple args #27

Closed tylersticka closed 8 years ago

tylersticka commented 8 years ago

Sometimes it's helpful when prototyping to be able to pass along multiple arguments to choose from at random instead of an array. See lib/random.js example for more info.


@erikjung @mrgerardorodriguez

erikjung commented 8 years ago

👍

gerardo-rodriguez commented 8 years ago

Nice! 👍

tylersticka commented 8 years ago

@erikjung @mrgerardorodriguez While I'm in here changing stuff, how crazy would it be to rename this to something like randomItem? I'm making a different helper for a prototype I'm working on that piggy-backs on chance to generate almost any random content:

{{random}} //=> 19854343893
{{random min=1 max=10}} //=> 7
{{random "dollar" max=20}} //=> $17.43
{{random "cc" type="Mastercard"}} //=> 5171206237468496
{{random "sentence" words=5}} //=> Waddik jeasmov cakgilta ficub up.

It started as a randomNumber helper, but I realized it wouldn't be difficult to open it up to any method... and I'm having a hard time thinking of a better word for this separate helper than {{random}}! 😆

gerardo-rodriguez commented 8 years ago

@tylersticka I'm cool with randomItem. 😉

erikjung commented 8 years ago

@tylersticka Considering the undocumented nature of these helpers, and that other projects using them are installing specific tags, I'm fine with renaming it to randomItem.

tylersticka commented 8 years ago

@erikjung @mrgerardorodriguez Rename achieved. 👍

Let me know if this is still looking okay for a merge. I figured I'd wait to bump the version till my next PR (the new helper I set out to write in the first place).

erikjung commented 8 years ago

👍