We're using a few helpers and utils in many our apps. Here are a few most used of them.
- isEq val1 val2 -> e.g. {#if isEq 'a' value} ... {/if}
- isIn val array -> e.g. {#if isIn 'a' array} ... {/if}
- oneOf val1 val2 -> {#if oneOf good bad} Show message if good or bad are true {/if}
- formatDate datetime, format -> will return given date in selected format
- compact: "DD.MM"
- short: "DD.MM.YYYY"
- long: "DD MMMM YYYY (ddd)"
- txt: "DD MMM"
- monthByNumber month -> e.g. {{monthByNumber 1}} will return "January"
arr.unique
-> returns array of uniq values or arrarr.merge(arr2)
-> merge two arraysarr.exclude(element)
-> will not touch original array, return array without elementarr.remove(element)
-> will remove element from original arrayarr.clean()
-> will delete allundefined
elements from array
Sometimes we want to use some function as property, e.g.
class Foo
@property onePlusTwo: -> "Result is #{1+2}"
x = new Foo
alert(x.onePlusTwo) # Will alert "Result is 3", don't need to call onePlusTwo() function
- srt.capitalize -> will capitalize given string (first letter will be capitalized)