Sha256: a9d797644d621e9921a4ea8077ff0d424b5d46429b28ac04e390d3f8a7390a10

Contents?: true

Size: 548 Bytes

Versions: 3

Compression:

Stored size: 548 Bytes

Contents

# Require core library
require 'middleman-core'

# Extension namespace
class AssetHttpPrefix < ::Middleman::Extension
  helpers do
    def asset_url(path, prefix = '', **options)
      begin
        original_output = super
      rescue
        original_output = super(path, prefix)
      end

      if config[:asset_http_prefix]
        original_output.sub(
          /^#{Regexp.escape(config[:http_prefix])}/, config[:asset_http_prefix])
      else
        original_output
      end
    end
  end
end

AssetHttpPrefix.register(:asset_http_prefix)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
middleman-asset-http-prefix-0.0.3 lib/middleman-asset-http-prefix.rb
middleman-asset-http-prefix-0.0.2 lib/middleman-asset-http-prefix.rb
middleman-asset-http-prefix-0.0.1 lib/middleman-asset-http-prefix.rb