Class: Middleman::Extensions::AssetHost

Inherits:
Middleman::Extension show all
Defined in:
lib/middleman-more/extensions/asset_host.rb

Overview

Asset Host module

Instance Attribute Summary

Attributes inherited from Middleman::Extension

#app, #options

Instance Method Summary collapse

Methods inherited from Middleman::Extension

activate, activated_extension, after_extension_activated, clear_after_extension_callbacks, config, extension_name, helpers, option, register

Constructor Details

#initialize(app, options_hash = {}, &block) ⇒ AssetHost

Returns a new instance of AssetHost.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/middleman-more/extensions/asset_host.rb', line 6

def initialize(app, options_hash={}, &block)
  super

  # Backwards compatible API
  app.config.define_setting :asset_host, nil, 'The asset host to use, or false for no asset host, or a Proc to determine asset host'

  app.compass_config do |config|
    if asset_host = extensions[:asset_host].host
      if asset_host.is_a?(Proc)
        config.asset_host(&asset_host)
      else
        config.asset_host do |asset|
          asset_host
        end
      end
    end
  end if app.respond_to?(:compass_config)
end

Instance Method Details

#hostObject



25
26
27
# File 'lib/middleman-more/extensions/asset_host.rb', line 25

def host
  app.config[:asset_host] || options[:host]
end