Module: Compass::SassExtensions::Functions::Urls::FontUrl
- Defined in:
- lib/compass/sass_extensions/functions/urls.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/compass/sass_extensions/functions/urls.rb', line 43 def self.included(base) if base.respond_to?(:declare) base.declare :font_url, [:path] base.declare :font_url, [:path, :only_path] end end |
Instance Method Details
#font_url(path, only_path = Sass::Script::Bool.new(false)) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/compass/sass_extensions/functions/urls.rb', line 49 def font_url(path, only_path = Sass::Script::Bool.new(false)) path = path.value # get to the string value of the literal. # Short curcuit if they have provided an absolute url. if absolute_path?(path) return Sass::Script::String.new("url(#{path})") end # Compute the path to the font file, either root relative or stylesheet relative # or nil if the http_fonts_path cannot be determined from the configuration. http_fonts_path = if relative? compute_relative_path(Compass.configuration.fonts_path) else Compass.configuration.http_fonts_path end path = "#{http_fonts_path}/#{path}" if only_path.to_bool Sass::Script::String.new(clean_path(path)) else clean_url(path) end end |