# directory-encoder

> Encode a directory of images to CSS

Latest version **0.9.2** (published 2017-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install directory-encoder
pnpm add directory-encoder
yarn add directory-encoder
bun add directory-encoder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.2 |
| Published | 2017-06-26 |
| First published | 2013-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | John Bender/Jeffrey Lembeck/Filament Group |
| Maintainers | filamentgroup-admin, johnmbender, maggiewachs, scottjehl, zachleat |

## Links

- npm: https://www.npmjs.com/package/directory-encoder
- Repository: https://github.com/filamentgroup/directory-encoder
- Issues: https://github.com/filamentgroup/directory-encoder/issues
- npm.io page: https://npm.io/package/directory-encoder

## Dependencies (3)

- [fs-extra](https://npm.io/package/fs-extra.md) ^1.0.0
- [img-stats](https://npm.io/package/img-stats.md) ^0.5.2
- [handlebars](https://npm.io/package/handlebars.md) ^4.0.6

## Recent versions

- 0.9.2 (latest) — 2017-06-26
- 0.9.1 — 2016-12-04
- 0.9.0 — 2016-12-03
- 0.8.1 — 2016-05-09
- 0.8.0 — 2016-02-01
- 0.7.2 — 2015-08-10
- 0.7.1 — 2015-04-27
- 0.7.0 — 2015-03-25
- 0.6.1 — 2014-12-29
- 0.6.0 — 2014-12-18
- 0.5.0 — 2014-04-22
- 0.4.0 — 2013-12-27
- 0.3.7 — 2013-12-26
- 0.3.6 — 2013-12-17
- 0.3.4 — 2013-12-16
- … 6 more at https://npm.io/package/directory-encoder/versions

## README

# directory-encoder [![Build Status](https://secure.travis-ci.org/filamentgroup/directory-encoder.png?branch=master)](http://travis-ci.org/filamentgroup/directory-encoder)

[![Filament Group](http://filamentgroup.com/images/fg-logo-positive-sm-crop.png) ](http://www.filamentgroup.com/)

Encode a directory of PNG or SVG images to CSS

## Getting Started
Install the module with: `npm install directory-encoder`

```javascript
var DirectoryEncoder = require('directory-encoder');
var de = new DirectoryEncoder( source, destinationCSSFile, {
			pngfolder: pngfolder, //in case you need to link out for PNGs, like when the datauri is way too long
			customselectors: { "foo": [".bar", ".baz"]}, 
			prefix: ".icon-", // used to prefix the name of the file for the CSS classname, .icon- is the default
			templatePrepend: "/* start of icon-list */", // this string is prepended to the destinationCSSFile, defaults to ""
			handlebarsCallback: function(hbs) { /* configure handlebars, with custom helpers for example */ }, // callback to configure handlebars
			template: template.hbs, //template in handlebars, FANCY!
			templateAppend: "/* end of icon-list */", // this string is appended to the destinationCSSFile, defaults to ""
			noencodepng: false // turn this to true if you want no datauris for pngs, just links out to png files
		});
de.encode(); // "Guitar solo -- File outputted"
```

## Documentation

### Constructor

Takes three arguments, source directory for encoding/an array of files
you'd like to encode, destination css
file for when it writes, and an options hash that includes a spot for
customselectors, a hbs template in case you want to get nuts with your
css, where the pngs are located if you want to link out to them (or you
don't have a choice because the data uri is bigger than 32k), and a
switch to turn off datauris for pngs.

### encode

All the magic happens here.

## Examples
```
var de = new DirectoryEncoder( source, destinationCSSFile, {
			pngfolder: pngfolder, //in case you need to link out for PNGs, like when the datauri is way too long
			customselectors: { "foo": [".bar", ".baz"]}, 
			template: template.hbs, //template in handlebars, FANCY!
			noencodepng: false // turn this to true if you want no datauris for pngs, just links out to png files
		});
de.encode(); // "Guitar solo -- File outputted"
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History

* 0.7.0  Add templateAppend and templatePrepend options
* 0.6.0  Fix encoding brackets and ability to take an array
* 0.5.0  PNGpath
* 0.4.0  Width/Height from template
* 0.3.0  Adding custom selectors that allow for wildcards
* 0.2.0  Adding switchable icon name prefixes
* 0.1.0  Woo

## License
Copyright (c) 2013 John Bender/Jeffrey Lembeck/Filament Group
Licensed under the MIT license.

---
_Source: https://npm.io/package/directory-encoder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
