Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

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

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.