module Sass::Script::Functions

Public Instance Methods

asset(url) click to toggle source
# File lib/maglove/tilt/scss_template.rb, line 3
def asset(url)
  assert_type url, :String
  Sass::Script::Value::String.new("url(\"#{Maglove::Engine.config.asset_uri}/#{url.value}\")")
end
asset_data(url) click to toggle source
# File lib/maglove/tilt/scss_template.rb, line 8
def asset_data(url)
  assert_type url, :String
  theme = options[:locals][:theme]
  asset_path = "dist/themes/#{theme}/#{url.value}"
  asset_contents = File.open(asset_path).read
  base64_string = Base64.strict_encode64(asset_contents)
  mime_type = Workspace.file(asset_path).mimetype
  data_uri = "data:#{mime_type};base64,#{base64_string}"
  Sass::Script::Value::String.new("url(#{data_uri})")
end