extensionify relative_assets
This commit is contained in:
parent
1c4e6cb835
commit
1d1f37d764
2 changed files with 23 additions and 41 deletions
|
@ -64,10 +64,8 @@ module Middleman
|
|||
|
||||
# RelativeAssets allow any asset path in dynamic templates to be either
|
||||
# relative to the root of the project or use an absolute URL.
|
||||
Middleman::Extensions.register(:relative_assets) do
|
||||
require "middleman-more/extensions/relative_assets"
|
||||
Middleman::Extensions::RelativeAssets
|
||||
end
|
||||
Middleman::Extensions::RelativeAssets.register
|
||||
|
||||
# GZIP assets and pages during build
|
||||
require "middleman-more/extensions/gzip"
|
||||
|
|
|
@ -1,30 +1,16 @@
|
|||
# Extension namespace
|
||||
module Middleman
|
||||
module Extensions
|
||||
# Relative Assets extension
|
||||
class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
||||
|
||||
# Relative Assets extension
|
||||
module RelativeAssets
|
||||
def initialize(app, options_hash={}, &block)
|
||||
super
|
||||
|
||||
# Setup extension
|
||||
class << self
|
||||
|
||||
# Once registered
|
||||
def registered(app)
|
||||
# Tell compass to use relative assets
|
||||
# After compass is setup, make it use the registered cache buster
|
||||
app.compass_config do |config|
|
||||
config.relative_assets = true
|
||||
end
|
||||
|
||||
# Include instance methods
|
||||
app.send :include, InstanceMethods
|
||||
end
|
||||
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
# Relative Assets instance method
|
||||
module InstanceMethods
|
||||
|
||||
helpers do
|
||||
# asset_url override for relative assets
|
||||
# @param [String] path
|
||||
# @param [String] prefix
|
||||
|
@ -40,6 +26,4 @@ module Middleman
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue