Formatting functions - misonou/waterpipe GitHub Wiki
Formatting functions are provided in a separate JavaScript file waterpipe.format.js.
Formats the piped value by the specified format. The function uses sprintf.js.
{{foo}} ➜ 65530
{{bar}} ➜ 0.5
{{foo :printf %x}} ➜ 65530
{{bar :printf %.2f}} ➜ 0.50
A shorthand syntax is also supported where the pipe function name itself is the formatting expression starting with the percent character (%).
{{foo %x}} -> 65530
{{bar %.2f}} -> 0.50
Converts key-value pairs from an object to a query string, or to be specific an application/x-www-form-urlencoded encoded string.
{{&values}} ➜ {foo:"baz",bar:1}
{{&values :query}} ➜ "foo=baz&bar=1"
Converts the timestamp or string to the equivalent date in the specified format. The function uses the standard and custom date and time format strings of Microsoft .NET Framework.
It is also useful to extract date and time components from the given timestamp or date string.
{{timestamp}} ➜ 1370000000000
{{date}} ➜ 2013-05-31
{{timestamp :date yyyy-MM-dd}} -> "2013-05-31"
{{timestamp :date f}} -> "Friday, 31 May 2013 19:33"
{{date :date f}} -> "Friday, 31 May 2013 08:00"
{{date :date M}} -> "5"