Module: Sass::Script::Functions

Defined in:
lib/prez/sass_extensions.rb

Instance Method Summary collapse

Instance Method Details

#twbs_font_path(path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/prez/sass_extensions.rb', line 4

def twbs_font_path(path)
  assert_type path, :String
  path = path.value.sub /[?#].*/, ""
  contents = Prez::Files.contents path, "font"
  extension = path[/\.([^.]*)$/, 1]

  case extension
  when "eot"
    font_type = "application/vnd.ms-fontobject"
  when "svg"
    font_type = "image/svg+xml"
  when "ttf"
    font_type = "font/ttf"
  when "woff"
    font_type = "application/font-woff"
  when "woff2"
    font_type = "application/font-woff2"
  else
    raise Prez::Error.new("Unknown font extension '#{extension}'")
  end

  Sass::Script::Value::String.new Prez::DataUri.new(font_type, contents).to_s
rescue Prez::Files::MissingError => e
  raise Prez::Error.new("Could not find font: '#{path}'")
end

#twbs_image_path(path) ⇒ Object



30
31
32
# File 'lib/prez/sass_extensions.rb', line 30

def twbs_image_path(path)
  Sass::Script::Value::String.new("ARGLE BARGLE IMAGE #{path.inspect}")
end