Skip to content

Instantly share code, notes, and snippets.

@Snugug
Created January 13, 2013 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Snugug/4525934 to your computer and use it in GitHub Desktop.
Save Snugug/4525934 to your computer and use it in GitHub Desktop.
def split_string(string, key)
items = string.value.split(" " + key.value + " ")
if items.count == 1
Sass::Script::Bool.new(false)
else
Sass::Script::List.new(items, :comma)
end
end
@Snugug
Copy link
Author

Snugug commented Jan 13, 2013

I get the following error when trying to return the List

The input is the following:

@debug split_string('1 2 3 4 5 at 500px', 'at');
NoMethodError on line 27 of /usr/local/gems/sass-3.2.5/lib/sass/../sass/script/node.rb: undefined method `options=' for "1 2 3 4 5":String

@Snugug
Copy link
Author

Snugug commented Jan 13, 2013

def split_string(string, key)
    items = string.value.split(" " + key.value + " ")
    if items.count == 1
      Sass::Script::Bool.new(false)
    else
      result = Array.new
      items.each_with_index do |elem, i|
        result[i] = Sass::Script::String.new(elem)
      end
      Sass::Script::List.new(result, :comma)
    end
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment