Module: Compass::Core::SassExtensions::Functions::Urls::FontUrl

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/urls.rb

### Methods

- ::included
- #font_url

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::Urls::FontUrl

### Public Class Methods

included(base) click to toggle source

    # File lib/compass/core/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]
        base.declare :font_url,       [:path, :only_path, :cache_buster]
      end
    end

### Public Instance Methods

font_url(path, only_path = bool(false), cache_buster = bool(true)) click to toggle source

    # File lib/compass/core/sass_extensions/functions/urls.rb, line 50
    def font_url(path, only_path = bool(false), cache_buster = bool(true))
      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 unquoted_string("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

      # Compute the real path to the font on the file system if the fonts_dir is set.
      real_path = if Compass.configuration.fonts_dir
        File.join(Compass.configuration.fonts_path, path.gsub(/[?#].*$/,""))
      end

      # prepend the path to the font if there's one
      if http_fonts_path
        http_fonts_path = "#{http_fonts_path}/" unless http_fonts_path[-1..-1] == "/"
        path = "#{http_fonts_path}#{path}"
      end

      # Compute the asset host unless in relative mode.
      asset_host = if !relative? && Compass.configuration.asset_host
        Compass.configuration.asset_host.call(path)
      end

      # Compute and append the cache buster if there is one.
      if cache_buster.to_bool
        path, anchor = path.split("#", 2)
        if cache_buster.is_a?(Sass::Script::Value::String)
          path += "#{path["?"] ? "&" : "?"}#{cache_buster.value}"
        else
          path = cache_busted_path(path, real_path)
        end
        path = "#{path}#{"#" if anchor}#{anchor}"
      end

      # prepend the asset host if there is one.
      path = "#{asset_host}#{'/' unless path[0..0] == "/"}#{path}" if asset_host

      if only_path.to_bool
        unquoted_string(clean_path(path))
      else
        clean_url(path)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.