Created
August 15, 2010 22:53
-
-
Save chriseppstein/526047 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sass' | |
module Sass::Script::Functions | |
def strip_unit(value) | |
Sass::Script::Number.new(value.value) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=unitless-value($property, $value) | |
@if unitless($value) | |
#{$property}: $value | |
@else if unit($value) == px | |
#{$property}: $value / 1px | |
@else if unit($value) == em | |
#{$property}: $value / 1em | |
@else | |
@warn "I wasn't expecting to find a #{unit($value)} value" | |
#{$property}: $value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sass -r strip_unit.rb unitless_clean_example.sass | |
div | |
foo: strip-unit(10px) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment