Skip to content

Instantly share code, notes, and snippets.

@Snugug Snugug/Sass.scss
Last active Dec 11, 2015

Embed
What would you like to do?
@function add-grid($grid-definition) {
$grid-split: split_string($grid-definition, ' at ');
$number: nth($grid-split, 2) * 1px;
@debug $number;
@debug type-of($number);
@return $number;
}
#foo {
$width: add-grid("5 at 500px");
@if ($width > 500px) {
width: 100%;
}
@else {
width: 80%;
}
}
module Sass::Script::Functions
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.map{|i| Sass::Script::String.new(i)}, :comma)
end
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.