Sha256: 081b87c40dcd1f977a743719c661ef744b2e3dd9871a72ec4bc9cbcf5de40628
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
# Extensions namespace module Middleman::Extensions # Asset Host module module AssetHost # Setup extension class << self # Once registered def registered(app) # Default to no host app.set :asset_host, false # Include methods app.send :include, InstanceMethods end alias :included :registered end # Asset Host Instance Methods module InstanceMethods # Override default asset url helper to include asset hosts # # @param [String] path # @param [String] prefix # @return [String] def asset_url(path, prefix="") original_output = super return original_output unless asset_host asset_prefix = if asset_host.is_a?(Proc) asset_host.call(original_output) elsif asset_host.is_a?(String) asset_host end File.join(asset_prefix, original_output) end end end # Register the extension register :asset_host, AssetHost end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
middleman-core-3.0.0.beta.3 | lib/middleman-core/extensions/asset_host.rb |
middleman-core-3.0.0.beta.2 | lib/middleman-core/extensions/asset_host.rb |