riot-format

1.1.1 • Public • Published

riot-format

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.

NPM version NPM downloads MIT License

why riot-format

  • 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

Get Started

install it from npm

npm install -D riot-format

Use it with riot

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>

Use it directly without riot

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

More

Plans

  • add currency support

License

MIT

Package Sidebar

Install

npm i riot-format

Weekly Downloads

13

Version

1.1.1

License

MIT

Last publish

Collaborators

  • joylei