extensionify relative_assets

This commit is contained in:
Thomas Reynolds 2013-04-20 14:33:18 -07:00
parent 1c4e6cb835
commit 1d1f37d764
2 changed files with 23 additions and 41 deletions

View file

@ -64,10 +64,8 @@ module Middleman
# RelativeAssets allow any asset path in dynamic templates to be either # RelativeAssets allow any asset path in dynamic templates to be either
# relative to the root of the project or use an absolute URL. # relative to the root of the project or use an absolute URL.
Middleman::Extensions.register(:relative_assets) do
require "middleman-more/extensions/relative_assets" require "middleman-more/extensions/relative_assets"
Middleman::Extensions::RelativeAssets Middleman::Extensions::RelativeAssets.register
end
# GZIP assets and pages during build # GZIP assets and pages during build
require "middleman-more/extensions/gzip" require "middleman-more/extensions/gzip"

View file

@ -1,30 +1,16 @@
# Extension namespace
module Middleman
module Extensions
# Relative Assets extension # Relative Assets extension
module RelativeAssets class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
# Setup extension def initialize(app, options_hash={}, &block)
class << self super
# Once registered # After compass is setup, make it use the registered cache buster
def registered(app)
# Tell compass to use relative assets
app.compass_config do |config| app.compass_config do |config|
config.relative_assets = true config.relative_assets = true
end end
# Include instance methods
app.send :include, InstanceMethods
end end
alias :included :registered helpers do
end
# Relative Assets instance method
module InstanceMethods
# asset_url override for relative assets # asset_url override for relative assets
# @param [String] path # @param [String] path
# @param [String] prefix # @param [String] prefix
@ -41,5 +27,3 @@ module Middleman
end end
end end
end end
end
end