Skip to content

Instantly share code, notes, and snippets.

@Snugug
Last active December 11, 2015 10:48
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/4589292 to your computer and use it in GitHub Desktop.
Save Snugug/4589292 to your computer and use it in GitHub Desktop.
@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