2 Star 1 Fork 0

joylei / riot-format

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
Liu Lei 提交于 2016-12-02 11:45 . add CDN

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

Get it from CDN

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

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

JavaScript
1
https://gitee.com/wowin/riot-format.git
git@gitee.com:wowin/riot-format.git
wowin
riot-format
riot-format
master

搜索帮助