Module: BranchableCDNAssets::Middleman::SassHelpers

Defined in:
lib/branchable_cdn_assets/middleman/helpers.rb

Instance Method Summary collapse

Instance Method Details

#application_contextObject

TODO: add a test that exercises this code



75
76
77
78
79
80
81
82
# File 'lib/branchable_cdn_assets/middleman/helpers.rb', line 75

def application_context
  if options.key?(:custom)
    options[:custom][:middleman_context] ||
      options[:custom][:sprockets_context]
  elsif options.key?(:sprockets)
    options[:sprockets][:context]
  end
end

#cdn_asset_path(path, cdn = nil) ⇒ Object



67
68
69
70
71
# File 'lib/branchable_cdn_assets/middleman/helpers.rb', line 67

def cdn_asset_path( path, cdn=nil )
  cdn  = cdn.value if cdn.respond_to?(:value) # have to force cdn to a string if not nil
  file = application_context.cdn_asset_url( path.value, cdn )
  ::Sass::Script::String.new file, :string
end

#cdn_asset_url(path, cdn = nil) ⇒ Object



63
64
65
# File 'lib/branchable_cdn_assets/middleman/helpers.rb', line 63

def cdn_asset_url( path, cdn=nil )
  ::Sass::Script::String.new("url(#{cdn_asset_path(path, cdn)})")
end