sass-json-vars 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sass-json-vars/importer.rb +6 -2
- data/lib/sass-json-vars/version.rb +1 -1
- data/readme.md +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35752407d8d32e59704d19bfa5996091cab97921
|
4
|
+
data.tar.gz: 5286c5e298cf7136dcaef29b36231e10d71cfa76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cec12e1b9af79066612bd52ae3ced0ea576bb3277d619a808620e28d439249c87e50a9295cf75662ebf016ba720c55d665d7906e6d0d3121645cdaa2c1589a0
|
7
|
+
data.tar.gz: f6d16d35f9a7cd2faf25ffda1f58a9f14ba7584f66c26f24df7ff2de161155dc461859b8abc5d02ef1de09a896f061152723529f1030e85b2e20ee014806bd2c
|
@@ -28,9 +28,13 @@ module SassJSONVars
|
|
28
28
|
return unless full_filename && File.readable?(full_filename)
|
29
29
|
|
30
30
|
json = JSON.parse(IO.read(full_filename))
|
31
|
-
variables = json.map { |key, value| "$#{key}: #{_convert_to_sass(value)}" }.join("\n")
|
31
|
+
variables = json.map { |key, value| "$#{key}: #{_convert_to_sass(value)};" }.join("\n")
|
32
32
|
|
33
|
-
Sass::Engine.new(variables
|
33
|
+
Sass::Engine.new(variables, options.merge(
|
34
|
+
:filename => full_filename,
|
35
|
+
:importer => self,
|
36
|
+
:syntax => :scss
|
37
|
+
))
|
34
38
|
end
|
35
39
|
|
36
40
|
def _convert_to_sass(item)
|
data/readme.md
CHANGED
@@ -7,12 +7,18 @@
|
|
7
7
|
|
8
8
|
`@import` json data into Sass `$variables`.
|
9
9
|
|
10
|
+
|
11
|
+
**Important:** the latest version of [`sass-rails`](https://github.com/rails/sass-rails) is locked in to Sass 3.2. This means that [Sass maps](http://thesassway.com/news/sass-3-3-released#maps) are not available to `sass-json-vars` to parse nested objects.
|
12
|
+
|
10
13
|
### Usage
|
11
14
|
|
12
15
|
```shell
|
13
16
|
gem install sass-json-vars
|
14
17
|
```
|
15
18
|
|
19
|
+
#### For projects using Sass >= 3.3
|
20
|
+
|
21
|
+
|
16
22
|
Place variables in a JSON file:
|
17
23
|
|
18
24
|
```javascript
|
@@ -36,6 +42,36 @@ body {
|
|
36
42
|
}
|
37
43
|
```
|
38
44
|
|
45
|
+
Require sass-json-vars when compiling
|
46
|
+
|
47
|
+
```shell
|
48
|
+
sass style.scss -r sass-json-vars
|
49
|
+
```
|
50
|
+
|
51
|
+
#### For projects using Sass <= 3.2
|
52
|
+
|
53
|
+
Place variables in a JSON file:
|
54
|
+
|
55
|
+
```javascript
|
56
|
+
// variables.json
|
57
|
+
{
|
58
|
+
"font-sans": "Helvetica, sans-serif",
|
59
|
+
"colors-red": "#c33"
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
Import the file in Sass to expose variable names:
|
64
|
+
|
65
|
+
```scss
|
66
|
+
@import "variables.json"
|
67
|
+
|
68
|
+
body {
|
69
|
+
color: $colors-red;
|
70
|
+
font: $font-sans;
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
74
|
+
|
39
75
|
Require sass-json-vars when compiling
|
40
76
|
|
41
77
|
```shell
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-json-vars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Hunzaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|