Module: Compass::SassExtensions::Functions::InlineImage

Included in:
Sass::Script::Functions
Defined in:
lib/compass/sass_extensions/functions/inline_image.rb

Instance Method Summary collapse

Instance Method Details

#inline_font_files(*args) ⇒ Object

Raises:

  • (Sass::SyntaxError)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/compass/sass_extensions/functions/inline_image.rb', line 11

def inline_font_files(*args)
  raise Sass::SyntaxError, "An even number of arguments must be passed to font_files()" unless args.size % 2 == 0
  path = path.value
  files = []
  while args.size > 0
    path = args.shift.value
    real_path = File.join(Compass.configuration.fonts_path, path)
    url = "url('data:#{compute_mime_type(path,mime_type)};base64,#{data(real_path)}')"
    files << "#{url} format('#{args.shift}')"
  end
  Sass::Script::String.new(files.join(", "))
end

#inline_image(path, mime_type = nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/compass/sass_extensions/functions/inline_image.rb', line 4

def inline_image(path, mime_type = nil)
  path = path.value
  real_path = File.join(Compass.configuration.images_path, path)
  url = "url('data:#{compute_mime_type(path,mime_type)};base64,#{data(real_path)}')"
  Sass::Script::String.new(url)
end