Module: Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl

Defined in:
lib/compass/core/sass_extensions/functions/urls.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



16
17
18
19
20
21
# File 'lib/compass/core/sass_extensions/functions/urls.rb', line 16

def self.included(base)
  if base.respond_to?(:declare)
    base.declare :stylesheet_url, [:path]
    base.declare :stylesheet_url, [:path, :only_path]
  end
end

Instance Method Details

#stylesheet_url(path, only_path = bool(false)) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/compass/core/sass_extensions/functions/urls.rb', line 22

def stylesheet_url(path, only_path = bool(false))
  # Compute the path to the stylesheet, either root relative or stylesheet relative
  # or nil if the http_images_path is not set in the configuration.
  http_stylesheets_path = if relative?
    compute_relative_path(Compass.configuration.css_path)
  elsif Compass.configuration.http_stylesheets_path
    Compass.configuration.http_stylesheets_path
  else
    Compass.configuration.http_root_relative(Compass.configuration.css_dir)
  end

  path = "#{http_stylesheets_path}/#{path.value}"
  if only_path.to_bool
    unquoted_string(clean_path(path))
  else
    clean_url(path)
  end
end