Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Useful functions for sass
module Sass::Script
module Functions
# substitue text in a string
# @params
# str the string to substitute text from
# reg the regexp given to sub
# rep the replacement text
def sub(str, reg, rep = '')
Sass::Script::String.new(str.to_s.sub(/#{reg.to_s}/, rep.to_s))
end
# Returns the width in pixels of an image
def width(path)
Sass::Script::Number.new(img_identify(path, 'w').to_i , ["px"])
end
# Returns the height in pixels of an image
def height(path)
Sass::Script::Number.new(img_identify(path, 'h').to_i, ["px"])
end
private
def img_identify(path, f)
path = path.to_s
if path[0].chr == '/'
path = Merb.root / 'public' / path
else
path = Sass::Plugin.options[:css_location] / path
end
`identify -format %#{f}\\\\n #{path}`.split("\n")[0]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.