Sha256: 112eb6c8ed706753df5db699e2637ea540c80b122065bb86c3a529bf7ab5f5f7
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
# Asset Host module class Middleman::Extensions::AssetHost < ::Middleman::Extension option :host, nil, 'The asset host to use, or false for no asset host, or a Proc to determine asset host' 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 end def host app.config[:asset_host] || options[:host] end helpers do # Override default asset url helper to include asset hosts # # @param [String] path # @param [String] prefix # @return [String] def asset_url(path, prefix="") controller = extensions[:asset_host] original_output = super return original_output unless controller.host asset_prefix = if controller.host.is_a?(Proc) controller.host.call(original_output) elsif controller.host.is_a?(String) controller.host end File.join(asset_prefix, original_output) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
middleman-more-3.1.0.beta.3 | lib/middleman-more/extensions/asset_host.rb |
middleman-more-3.1.0.beta.2 | lib/middleman-more/extensions/asset_host.rb |