Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/strarsis/eyeglass-file-text
Sass eyeglass module for getting the contents of a text file as string
https://github.com/strarsis/eyeglass-file-text
Last synced: 13 days ago
JSON representation
Sass eyeglass module for getting the contents of a text file as string
- Host: GitHub
- URL: https://github.com/strarsis/eyeglass-file-text
- Owner: strarsis
- Created: 2015-09-15T21:31:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-18T14:49:45.000Z (about 8 years ago)
- Last Synced: 2024-10-18T23:55:15.123Z (about 1 month ago)
- Language: JavaScript
- Size: 124 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eyeglass-file-text
Sass eyeglass module for getting the contents of text or binary files as (encoded) string.
[![david](https://david-dm.org/strarsis/eyeglass-file-text.svg)](https://david-dm.org/strarsis/eyeglass-file-text)
[![NPM](https://nodei.co/npm/eyeglass-file-text.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/eyeglass-file-text/)
New: Supports binary files now (encodes to base64).
New: Normalizes line endings to prevent issues with quotes and later output of the string.
Installation
------------
````
npm install --save-dev eyeglass-file-text
````Usage
-----
````
@import 'file-text';// Fetch text file:
$text : file-text('./loremipsum.txt');
// encoding can be explicitly specified by 2nd argument// Fetch binary file:
$base64: file-binary('./test.jpg');
// binary file content is represented as base64 text// The string can then be used as usual in sass:
.test-text {
content: $text;
}.test-binary {
background: url("data:image/jpeg;base64,#{$base64}");
}
````Arguments
---------
### file-text
#### path
Path to the file.#### encoding
Encoding of the file.
Defaults to utf8.### file-binary
#### path
Path to the file.