a helper library for riotjs to format displays, without external dependencies, inspired by $filter of angular.
The original idea is to make it work with riot, but it can also work without riot.
- no external dependencies
- built-in format: date(), number(), bytes(), json()
- chained format method calls
- easy to extend
- support modern browsers (IE9+)
- compatible with riot
- less than 5kb
CDN files:
https://cdn.jsdelivr.net/riot-format/1.1.1/riot-format.js
https://cdn.jsdelivr.net/riot-format/1.1.1/riot-format.min.js
https://cdn.jsdelivr.net/riot-format/1.1.1/riot-format.min.js.map
npm install -D riot-format
mixin
import format from 'riot-format'
import * as riot from 'riot'
format(riot) //mixin globally
use it in riot tag
<app>
<p>Today is { format(now, 'date', 'yyyy-mm-dd') }</p>
this.now = new Date()
<app>
import { format } from 'riot-format'
let formatter = format(new Date(), 'date', 'yyyy-mm-dd')
console.log(formatter.current)
//Note: formatter.current is lazily evaluated until you access it
For more information, see Get Started
- add currency support
MIT