sutty-liquid 0.11.4 → 0.11.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/filters/yaml_to_scss.rb +4 -39
- 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: a9bcc5adc518ebd74470acbf0b797a629482d627ae4e5b99f4aeb4115ea97059
|
4
|
+
data.tar.gz: f5b9de8760bbb070bff3b6e2f43dfa26f5a2c350e843cb0fede9a6d6b948708e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e88928c41e676ffef64066404b7db2fa90060dfb8bd0c8670c75fa85997b4bd4f2cb35f8a5b8427da5eeba131d11008fb8c44480b79ba5b567f2c448268ee953
|
7
|
+
data.tar.gz: 5842a7edc7fcb414f41616cedde4627be828d24d9ecaf4175a45a0b818c17e9d41d896580e7c33305316459b7e559da05a8cf1df6bdc375ed242ce1ba44422a3
|
@@ -4,11 +4,6 @@ module Jekyll
|
|
4
4
|
module Filters
|
5
5
|
# YAML to SCSS
|
6
6
|
module YamlToScss
|
7
|
-
# @see {https://sass-lang.com/documentation/values/strings#unquoted}
|
8
|
-
CSS_IDENTIFIER_SHORT = /\A-?[^0-9\s]+\z/
|
9
|
-
CSS_IDENTIFIER_LONG = /\A--[^\s]+\z/
|
10
|
-
SCSS_FUNCTION = /\A[0-9a-z]+\(/
|
11
|
-
|
12
7
|
# Converts a YAML object into SCSS. Only supports one level
|
13
8
|
# values.
|
14
9
|
#
|
@@ -29,12 +24,13 @@ module Jekyll
|
|
29
24
|
yaml.slice(*schema.keys).map do |key, value|
|
30
25
|
next if value.nil?
|
31
26
|
|
27
|
+
escape = schema[key].is_a?(Hash) && %w[image file].include?(schema.dig(key, 'type'))
|
32
28
|
key = key_to_scss key
|
33
29
|
|
34
30
|
case value
|
35
31
|
when Array
|
36
32
|
values = value.compact.map(&:to_s).reject(&:empty?).map do |v|
|
37
|
-
|
33
|
+
escape ? v.dump : v
|
38
34
|
end
|
39
35
|
|
40
36
|
"$#{key}: (#{values.join(',')},);"
|
@@ -44,7 +40,7 @@ module Jekyll
|
|
44
40
|
next if v.nil?
|
45
41
|
next if v.to_s.empty?
|
46
42
|
|
47
|
-
v = v.dump
|
43
|
+
v = v.dump if escape
|
48
44
|
|
49
45
|
"\"#{key_to_scss k}\": #{v}"
|
50
46
|
end
|
@@ -52,7 +48,7 @@ module Jekyll
|
|
52
48
|
"$#{key}: (#{values.join(',')},);"
|
53
49
|
else
|
54
50
|
next if value.to_s.empty?
|
55
|
-
value = value.dump
|
51
|
+
value = value.dump if escape
|
56
52
|
|
57
53
|
"$#{key}: #{value};"
|
58
54
|
end
|
@@ -68,37 +64,6 @@ module Jekyll
|
|
68
64
|
def key_to_scss(key)
|
69
65
|
key.to_s.tr '_', '-'
|
70
66
|
end
|
71
|
-
|
72
|
-
# Detects if value is a SCSS/SASS expression
|
73
|
-
#
|
74
|
-
# @param :value [Any]
|
75
|
-
# @return [Bool]
|
76
|
-
def scss_expression?(value)
|
77
|
-
return true unless value.is_a? String
|
78
|
-
# Quoted?
|
79
|
-
return false if value.start_with? '"'
|
80
|
-
return false if value.start_with? '\''
|
81
|
-
# Array/hash?
|
82
|
-
return true if value.start_with? '('
|
83
|
-
# Variable?
|
84
|
-
return true if value.start_with? '$'
|
85
|
-
# RGB color?
|
86
|
-
return true if value.start_with? '#'
|
87
|
-
# Negative number or CSS identifier?
|
88
|
-
return true if value.start_with? '-'
|
89
|
-
|
90
|
-
# Number?
|
91
|
-
(0..9).each do |i|
|
92
|
-
return true if value.start_with? i.to_s
|
93
|
-
end
|
94
|
-
|
95
|
-
# CSS identifier?
|
96
|
-
return true if CSS_IDENTIFIER_SHORT =~ value
|
97
|
-
return true if CSS_IDENTIFIER_LONG =~ value
|
98
|
-
return true if SCSS_FUNCTION =~ value
|
99
|
-
|
100
|
-
false
|
101
|
-
end
|
102
67
|
end
|
103
68
|
end
|
104
69
|
end
|