Module: Condenser::Sass::Functions

Included in:
Condenser::SassTransformer::Functions
Defined in:
lib/condenser/transformers/sass/functions.rb

Instance Method Summary collapse

Instance Method Details

#asset_data_url(path) ⇒ Object

Public: Generate a data URI for asset path.



108
109
110
111
# File 'lib/condenser/transformers/sass/functions.rb', line 108

def asset_data_url(path)
  url = condenser_environment.asset_data_uri(path.value)
  Sass::Script::String.new("url(" + url + ")")
end

#asset_path(path, options = {}) ⇒ Object

Public: Generate a url for asset path.

Defaults to Context#asset_path.



17
18
19
20
21
22
23
24
# File 'lib/condenser/transformers/sass/functions.rb', line 17

def asset_path(path, options = {})
  condenser_context.link_asset(path)

  path = condenser_context.asset_path(path, options)
  query    = "?#{query}" if query
  fragment = "##{fragment}" if fragment
  "#{path}#{query}#{fragment}"
end

#asset_path_signatureObject



26
27
28
29
30
31
# File 'lib/condenser/transformers/sass/functions.rb', line 26

def asset_path_signature
  {
    "$path" => "String",
    "$options: ()" => 'Map'
  }
end

#asset_url(path, options = {}) ⇒ Object

Public: Generate a asset url() link.

path - String



36
37
38
# File 'lib/condenser/transformers/sass/functions.rb', line 36

def asset_url(path, options = {})
  "url(#{asset_path(path, options)})"
end

#asset_url_signatureObject



40
41
42
43
44
45
# File 'lib/condenser/transformers/sass/functions.rb', line 40

def asset_url_signature
  {
    "$path" => "String",
    "$options: ()" => 'Map'
  }
end

#audio_path(path) ⇒ Object

Public: Generate url for audio path.



68
69
70
# File 'lib/condenser/transformers/sass/functions.rb', line 68

def audio_path(path)
  asset_path(path, type: :audio)
end

#audio_url(path) ⇒ Object

Public: Generate a audio url() link.



73
74
75
# File 'lib/condenser/transformers/sass/functions.rb', line 73

def audio_url(path)
  asset_url(path, type: :audio)
end

#font_path(path) ⇒ Object

Public: Generate url for font path.



78
79
80
# File 'lib/condenser/transformers/sass/functions.rb', line 78

def font_path(path)
  asset_path(path, type: :font)
end

#font_url(path) ⇒ Object

Public: Generate a font url() link.



83
84
85
# File 'lib/condenser/transformers/sass/functions.rb', line 83

def font_url(path)
  asset_url(path, type: :font)
end

#image_path(path) ⇒ Object

Public: Generate url for image path.



48
49
50
# File 'lib/condenser/transformers/sass/functions.rb', line 48

def image_path(path)
  asset_path(path, type: :image)
end

#image_url(path) ⇒ Object

Public: Generate a image url() link.



53
54
55
# File 'lib/condenser/transformers/sass/functions.rb', line 53

def image_url(path)
  asset_url(path, type: :image)
end

#javascript_path(path) ⇒ Object

Public: Generate url for javascript path.



88
89
90
# File 'lib/condenser/transformers/sass/functions.rb', line 88

def javascript_path(path)
  asset_path(path, type: :javascript)
end

#javascript_url(path) ⇒ Object

Public: Generate a javascript url() link.



93
94
95
# File 'lib/condenser/transformers/sass/functions.rb', line 93

def javascript_url(path)
  asset_url(path, type: :javascript)
end

#stylesheet_path(path) ⇒ Object

Public: Generate url for stylesheet path.



98
99
100
# File 'lib/condenser/transformers/sass/functions.rb', line 98

def stylesheet_path(path)
  asset_path(path, type: :stylesheet)
end

#stylesheet_url(path) ⇒ Object

Public: Generate a stylesheet url() link.



103
104
105
# File 'lib/condenser/transformers/sass/functions.rb', line 103

def stylesheet_url(path)
  asset_url(path, type: :stylesheet)
end

#video_path(path) ⇒ Object

Public: Generate url for video path.



58
59
60
# File 'lib/condenser/transformers/sass/functions.rb', line 58

def video_path(path)
  asset_path(path, type: :video)
end

#video_url(path) ⇒ Object

Public: Generate a video url() link.



63
64
65
# File 'lib/condenser/transformers/sass/functions.rb', line 63

def video_url(path)
  asset_url(path, type: :video)
end