nunjucks-date

2019-07-14 admin

nunjucks-date是什么

什么是nunjucks-date,Plugin for nunjucks of momentjs format date

nunjucks-date使用教程帮助文档

nunjucks-date

NPM version

Plugin for nunjucks of momentjs’ format date

Dependency Status Build Status Code Climate Test Coverage Coverage Status

Installation

npm install nunjucks-date --save

Usage

// Import the plugin
var nunjucksDate = require('nunjucks-date');

// Define a custom default date format. Any valid format works.
// The date format defaults to "YYYY"
// http://momentjs.com/docs/#/displaying/format/
nunjucksDate.setDefaultFormat('MMMM Do YYYY, h:mm:ss a');

// Initialize your Nunjucks enironment
var env = new nunjucks.Environment();

Using default name : ‘date’

// Pass the environment to `install()`
nunjucksDate.install(env);

Using custom name

// Pass the environment & a custom filter name
nunjucksDate.install(env, 'yourFilterName');

The above is eqivalent to

env.addFilter('date', require('nunjucks-date'));

Tests

  • Uses mocha to run tests & istanbul to generate code coverage metrics.
  • Test framework: Mocha.
  • Test coverage: Istanbul is a tool.
  • Istanbul CLI: nyc
npm test
npm test --coverage
open coverage/lcov-report/index.html

Contributing

Contributions are welcome. Please file issues with any problems that you experience. Pull requests are welcome.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69700.html

文章标题:nunjucks-date

回到顶部