summaryrefslogtreecommitdiff
path: root/config/initializers/sass_extensions.rb
blob: 984f1ae057df32557a36d1c72689ddc28aac5054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##
## define here new extensions you want available in sass stylesheets.
##

module Sass::Script::Functions

  #
  # takes a border string, like '1px solid green'
  # and returns 1px
  #
  def border_width(string)
    string = string.to_s
    if string =~ /px/
      Sass::Script::Number.new(string.split(' ').first.to_i, ['px'])
    else
      Sass::Script::Number.new(0,['px'])
    end
  end

  def border_color(string)
    assert_type string, :String
    Sass::Script::String.new(string.to_s.split(' ').last)
  end

end