Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created August 15, 2010 22:53
Show Gist options
  • Save chriseppstein/526047 to your computer and use it in GitHub Desktop.
Save chriseppstein/526047 to your computer and use it in GitHub Desktop.
require 'sass'
module Sass::Script::Functions
def strip_unit(value)
Sass::Script::Number.new(value.value)
end
end
=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
// 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