compass is converted to new ext. All done in -more

This commit is contained in:
Thomas Reynolds 2013-04-20 15:07:00 -07:00
parent 2500e4d35d
commit a463be3432
2 changed files with 72 additions and 85 deletions

View file

@ -31,14 +31,14 @@ module Middleman
# exist anymore. # exist anymore.
::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}} ::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}}
::I18n.reload! ::I18n.reload!
end end if ENV["TEST"]
require "middleman-more/core_extensions/i18n" require "middleman-more/core_extensions/i18n"
Middleman::CoreExtensions::Internationalization.register(:i18n) Middleman::CoreExtensions::Internationalization.register(:i18n)
# Compass framework # Compass framework
require "middleman-more/core_extensions/compass" require "middleman-more/core_extensions/compass"
Middleman::Application.register Middleman::CoreExtensions::Compass Middleman::CoreExtensions::Compass.new(app)
### ###
# Setup Optional Extensions # Setup Optional Extensions

View file

@ -1,15 +1,8 @@
module Middleman class Middleman::CoreExtensions::Compass < ::Middleman::Extension
module CoreExtensions
# Forward the settings on config.rb and the result of registered def initialize(app, options_hash={}, &block)
# extensions to Compass super
module Compass
# Extension registered
class << self
# Once registered
def registered(app)
# Require the library # Require the library
require "compass" require "compass"
@ -21,20 +14,21 @@ module Middleman
# @return [Array] # @return [Array]
# config[:sass_assets_paths] = ["#{root}/assets/sass/", "/path/2/external/sass/repository/"] # config[:sass_assets_paths] = ["#{root}/assets/sass/", "/path/2/external/sass/repository/"]
app.config.define_setting :sass_assets_paths, [], 'Paths to extra SASS/SCSS files' app.config.define_setting :sass_assets_paths, [], 'Paths to extra SASS/SCSS files'
end
app.after_configuration do def after_configuration
::Compass.configuration do |compass_config| ::Compass.configuration do |compass_config|
compass_config.project_path = source_dir compass_config.project_path = app.source_dir
compass_config.environment = :development compass_config.environment = :development
compass_config.cache_path = config[:sass_cache_path] compass_config.cache_path = app.config[:sass_cache_path]
compass_config.sass_dir = config[:css_dir] compass_config.sass_dir = app.config[:css_dir]
compass_config.css_dir = config[:css_dir] compass_config.css_dir = app.config[:css_dir]
compass_config.javascripts_dir = config[:js_dir] compass_config.javascripts_dir = app.config[:js_dir]
compass_config.fonts_dir = config[:fonts_dir] compass_config.fonts_dir = app.config[:fonts_dir]
compass_config.images_dir = config[:images_dir] compass_config.images_dir = app.config[:images_dir]
compass_config.http_path = config[:http_prefix] compass_config.http_path = app.config[:http_prefix]
config[:sass_assets_paths].each do |path| app.config[:sass_assets_paths].each do |path|
compass_config.add_import_path path compass_config.add_import_path path
end end
@ -54,7 +48,7 @@ module Middleman
end end
# Call hook # Call hook
run_hook :compass_config, ::Compass.configuration app.run_hook :compass_config, ::Compass.configuration
# Tell Tilt to use it as well (for inline sass blocks) # Tell Tilt to use it as well (for inline sass blocks)
::Tilt.register 'sass', CompassSassTemplate ::Tilt.register 'sass', CompassSassTemplate
@ -64,11 +58,6 @@ module Middleman
::Tilt.register 'scss', CompassScssTemplate ::Tilt.register 'scss', CompassScssTemplate
::Tilt.prefer(CompassScssTemplate) ::Tilt.prefer(CompassScssTemplate)
end end
end
alias :included :registered
end
end
# A Compass Sass template for Tilt, adding our options in # A Compass Sass template for Tilt, adding our options in
class CompassSassTemplate < ::Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate class CompassSassTemplate < ::Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate
@ -83,6 +72,4 @@ module Middleman
super.merge(::Compass.configuration.to_sass_engine_options) super.merge(::Compass.configuration.to_sass_engine_options)
end end
end end
end
end end