Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/techmsi/nunjucks-date
Plugin for nunjucks of momentjs' format date
https://github.com/techmsi/nunjucks-date
Last synced: 2 months ago
JSON representation
Plugin for nunjucks of momentjs' format date
- Host: GitHub
- URL: https://github.com/techmsi/nunjucks-date
- Owner: techmsi
- License: mit
- Created: 2014-07-24T12:22:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-05T12:27:53.000Z (over 4 years ago)
- Last Synced: 2024-09-20T15:27:42.325Z (4 months ago)
- Language: JavaScript
- Size: 1.24 MB
- Stars: 13
- Watchers: 0
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# nunjucks-date
[![NPM version](https://badge.fury.io/js/nunjucks-date.svg)](http://badge.fury.io/js/nunjucks-date)
Plugin for nunjucks of momentjs' format date
[![CircleCI](https://circleci.com/gh/techmsi/nunjucks-date.svg?style=svg)](https://circleci.com/gh/techmsi/nunjucks-date)
[![Build Status](https://travis-ci.org/techmsi/nunjucks-date.svg?branch=master)](https://travis-ci.org/techmsi/nunjucks-date)
[![Code Climate](https://codeclimate.com/github/techmsi/nunjucks-date/badges/gpa.svg)](https://codeclimate.com/github/techmsi/nunjucks-date)
[![Coverage Status](https://coveralls.io/repos/techmsi/nunjucks-date/badge.svg?branch=master)](https://coveralls.io/r/techmsi/nunjucks-date?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/techmsi/nunjucks-date.svg)](https://greenkeeper.io/)## Installation
```bash
npm install nunjucks-date --save
```## Usage
```js
// 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'
```js
// Pass the environment to `install()`
nunjucksDate.install(env);
```### Using custom name
```js
// Pass the environment & a custom filter name
nunjucksDate.install(env, "yourFilterName");
```The above is eqivalent to
```js
env.addFilter("date", require("nunjucks-date"));
```## Tests
- Uses `jest` to run tests to generate code coverage metrics.
```bash
npm test
``````bash
open coverage/lcov-report/index.html
```## Contributing
Contributions are welcome. Please file issues with any problems that you experience. Pull requests are welcome.