0.1.3 • Published 7 years ago
eyeglass-sassy-data v0.1.3
Sassy Data
Sassy Data is an eyeglass module which introduces functionality to import data from supported data formats to Sass maps or arrays. Currently, the supported data formats are:
- JSON
- YAML
Thanks to eyeglass-file-text for providing the functionality of reading files.
Installing
npm install --save eyeglass-sassy-data
# or
yarn add eyeglass-sassy-data
Then in your Sass files:
@import "sassy-data";
API
read-file($filePath, $encoding: $sd-default-encoding)
- Read the text of a file into a Sass stringjson-to-map($jsonAsString)
- Convert a string containing JSON into a Sass map/arrayyaml-to-map($yamlAsString)
- Convert a string containing YAML into a Sass map/arrayimport-json($filePath, $encoding: $sd-default-encoding)
- Read a JSON file and transform the contents into a Sass map/arrayimport-yaml($filePath, $encoding: $sd-default-encoding)
- Read a YAML file and transform the contents into a Sass map/array
Notes
- The default encoding for all files read can be set by overriding the
$sd-default-encoding
variable; the default is set to UTF-8. This encoding can be changed on a per-file basis by passing a value for the$encoding
parameter in the function calls - The file paths given should be relative to the Sass file calling the function (this does not mean the location of the Sassy Data function definitions)
License
MIT