0.0.3 • Published 9 years ago
json-to-css-bg-images v0.0.3
##api
var converter = require('json-to-css-bg-images')(images, options);
var result = converter.convert();
converter takes two arguments json array of objects
- `{array}` images - array of images
- `{object}` options - hash of options
Each hash in images array requires several properties
- `{string}` rules - string of css rules to add to each declaration (optional).
- `{array}` selectors - array of css selector strings to apply for each declaration (required).
- `{string}` src - string to be used as url src in bg image (required).
converter factory returns `convert` method, `convert` method returns:
- `{string}` css - stringified ast.
- `{object}` ast - ast in json.
##usage
```javascript
var converter = require('json-to-css-bg-images');([
{ "rules": "color: blue; margin: 0 0 0 0;", "selectors": [".blah", "div.flkj"], "src": "https://www.blah.com/image.jpg" },
{ "selectors": ["#deer"], "src": "https://www.flsdk.com/flkdj.jpg" }
]);
var result = converter.convert();
result.css; // =>
/**
* .blah, div.flkj {
* background-image: url(https://www.blah.com/image.jpg);
* color: blue;
* margin: 0 0 0 0;
* }
*
* #deer {
* background-image: url(https://www.flsdk.com/flkdj.jpg);
* }
*/