sassy-strings 0.2 → 0.2.1
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.
- data/lib/sassy-strings.rb +11 -7
- metadata +2 -1
data/lib/sassy-strings.rb
CHANGED
@@ -3,11 +3,13 @@ Compass::Frameworks.register("sassy-strings", :path => "#{File.dirname(__FILE__)
|
|
3
3
|
|
4
4
|
# Sassy String Functions
|
5
5
|
module Sass::Script::Functions
|
6
|
+
# Replace String
|
6
7
|
def str_replace(needle, replace, haystack)
|
7
8
|
result = haystack.value.to_s.gsub(needle.value.to_s, replace.value.to_s)
|
8
9
|
Sass::Script::String.new(result)
|
9
10
|
end
|
10
11
|
|
12
|
+
# Split String
|
11
13
|
def split_string(string, key)
|
12
14
|
items = string.value.split(key.value)
|
13
15
|
if items.count == 1
|
@@ -16,19 +18,21 @@ module Sass::Script::Functions
|
|
16
18
|
Sass::Script::List.new(items.map{|i| Sass::Script::String.new(i)}, :comma)
|
17
19
|
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
# String Position
|
23
|
+
def str_pos(needle, haystack)
|
24
|
+
if haystack.value.to_s.index(needle.value.to_s)
|
25
|
+
Sass::Script::Number.new(haystack.value.to_s.index(needle.value.to_s))
|
26
|
+
else
|
27
|
+
Sass::Script::Number.new(-1)
|
28
|
+
end
|
26
29
|
end
|
30
|
+
|
27
31
|
end
|
28
32
|
|
29
33
|
module SassyStrings
|
30
34
|
|
31
|
-
VERSION = "0.2"
|
35
|
+
VERSION = "0.2.1"
|
32
36
|
DATE = "2013-01-22"
|
33
37
|
|
34
38
|
end
|