sutty-liquid 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll/filters/yaml_to_scss.rb +24 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b85c3b8afb550ee71cfc8f66741b2359aa5555c6ffd1bb56a8c37b7d6fb7cb1a
|
|
4
|
+
data.tar.gz: 73e0cb289855212be762aaf241e407a871464cc719cdb223383b9d8fcc000058
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34b14645893b8f886893fbb6ce88644681d78623cfb267c768742ef136ba57b2f203418e1bcfd974db8452101810cd4ece30fec7004624f5690e37ac1619a0cb
|
|
7
|
+
data.tar.gz: c5b5130bb38d45e645169a00e968ea0afff20954786f23007310c50c38522e715063432ccaf0eb9d1c064a429747dde9fc19040737870dd7e5021dd91d2d7ffb
|
|
@@ -7,23 +7,43 @@ module Jekyll
|
|
|
7
7
|
# Converts a YAML object into SCSS. Only supports one level
|
|
8
8
|
# values.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
10
|
+
# Optionally give it an schema to filter out keys.
|
|
11
|
+
#
|
|
12
|
+
# @param :yaml [Hash,Jekyll::Drops::DocumentDrop]
|
|
13
|
+
# @param :schema [Hash]
|
|
11
14
|
# @return [String]
|
|
12
|
-
def yaml_to_scss(yaml)
|
|
13
|
-
yaml.
|
|
15
|
+
def yaml_to_scss(yaml, schema = yaml)
|
|
16
|
+
yaml = yaml.to_h if yaml.is_a? Jekyll::Drops::DocumentDrop
|
|
17
|
+
|
|
18
|
+
unless yaml.is_a? Hash
|
|
19
|
+
raise Liquid::ArgumentError, "#{yaml.inspect} needs to be a Hash" if @context.strict_filters
|
|
20
|
+
|
|
21
|
+
return yaml
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
yaml.slice(*schema.keys).map do |key, value|
|
|
25
|
+
next if value.nil?
|
|
26
|
+
|
|
14
27
|
key = key_to_scss key
|
|
15
28
|
|
|
16
29
|
case value
|
|
17
30
|
when Array
|
|
18
|
-
|
|
31
|
+
values = value.compact.map(&:to_s).reject(:empty?)
|
|
32
|
+
|
|
33
|
+
"$#{key}: (#{values.join(',')},);"
|
|
19
34
|
when Hash
|
|
20
35
|
values =
|
|
21
36
|
value.map do |k, v|
|
|
37
|
+
next if v.nil?
|
|
38
|
+
next if v.to_s.empty?
|
|
39
|
+
|
|
22
40
|
"\"#{key_to_scss k}\": #{v}"
|
|
23
41
|
end
|
|
24
42
|
|
|
25
43
|
"$#{key}: (#{values.join(',')},);"
|
|
26
44
|
else
|
|
45
|
+
next if value.to_s.empty?
|
|
46
|
+
|
|
27
47
|
"$#{key}: #{value};"
|
|
28
48
|
end
|
|
29
49
|
end.join("\n")
|