Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nymag/nunjucks-filters
Nunjucks environment and filters
https://github.com/nymag/nunjucks-filters
Last synced: 23 days ago
JSON representation
Nunjucks environment and filters
- Host: GitHub
- URL: https://github.com/nymag/nunjucks-filters
- Owner: nymag
- License: mit
- Created: 2015-03-18T21:45:26.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-23T14:03:12.000Z (almost 8 years ago)
- Last Synced: 2024-11-11T21:23:17.341Z (about 2 months ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 17
- Watchers: 49
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nunjucks-filters
[![Build Status](https://travis-ci.org/nymag/nunjucks-filters.svg)](https://travis-ci.org/nymag/nunjucks-filters)
[![Code Climate](https://codeclimate.com/github/nymag/nunjucks-filters/badges/gpa.svg)](https://codeclimate.com/github/nymag/nunjucks-filters)Nunjucks environment and filters
# Installation
```
npm install --save nunjucks-filters
```# Usage
Simply require it in your `app.js` file
```js
var app = require('express')(),
nunjucks = require('nunjucks-filters')();app.engine('nunjucks', nunjucks);
```## Passing env in
If you want to configure and use your own nunjucks environment, you can pass it through
```js
var nunjucks = require('nunjucks'),
env = nunjucks.configure('.', { custom: 'options' }),
filters = require('nunjucks-filters');filters(env);
```## Getting env out
Nunjucks-filters returns its nunjucks environment (including any env passed into it), so you can easily add your own filters and globals.
```js
var env = require('nunjucks-filters')();// add a filter
env.addFilter('emoji', function () {
return '(⌐■_■)';
});// add a global
env.addGlobal('coolDude', 'Nelson Pecora');
```