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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad37c07acd7b187061dd8774f6040775d8f0955bcf8177c4b8df3fb2003a557e
4
- data.tar.gz: aa7c1b4b4870d2cfa24a872d6bbd0262dafbf69e56a5fad8287817c32efc553c
3
+ metadata.gz: b85c3b8afb550ee71cfc8f66741b2359aa5555c6ffd1bb56a8c37b7d6fb7cb1a
4
+ data.tar.gz: 73e0cb289855212be762aaf241e407a871464cc719cdb223383b9d8fcc000058
5
5
  SHA512:
6
- metadata.gz: 589ffafd3e6434604ba96f6a98ba770adef39255e6ef39a04171cb68512d289e6470de517c82e36b298c79cd9685789be0a184835e446a0b119c8724be2f50e1
7
- data.tar.gz: 218eca65ce050537c6c53a38c186a8ef5af66a779d3704c8f8fe2fee9025689f5c03af927b5681b109d2236f5be465c02ec4eae47832795629a805a10db1e806
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
- # @param :yaml [Hash]
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.map do |key, value|
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
- "$#{key}: (#{value.join(',')},);"
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")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutty-liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - f