2009-10-22 20:25:15 -04:00
|
|
|
require "sass"
|
2009-10-26 18:42:06 -04:00
|
|
|
require "compass"
|
2009-10-22 20:25:15 -04:00
|
|
|
|
|
|
|
class Middleman::Base
|
2010-09-04 23:26:48 -04:00
|
|
|
def scss(template, options={}, locals={})
|
|
|
|
options[:layout] = false
|
|
|
|
render :scss, template, options, locals
|
|
|
|
end
|
2010-01-20 18:22:40 -05:00
|
|
|
|
|
|
|
after_feature_init do
|
2009-10-26 18:42:06 -04:00
|
|
|
::Compass.configuration do |config|
|
2010-09-04 23:26:48 -04:00
|
|
|
config.cache_path = File.join(self.root, ".sass-cache") # For sassc files
|
2009-10-29 12:43:08 -04:00
|
|
|
config.project_path = self.root
|
|
|
|
config.sass_dir = File.join(File.basename(self.views), self.css_dir)
|
2010-09-04 23:26:48 -04:00
|
|
|
config.output_style = :nested
|
2009-11-30 14:32:02 -05:00
|
|
|
config.fonts_dir = File.join(File.basename(self.public), self.fonts_dir)
|
2009-10-29 12:43:08 -04:00
|
|
|
config.css_dir = File.join(File.basename(self.public), self.css_dir)
|
|
|
|
config.images_dir = File.join(File.basename(self.public), self.images_dir)
|
2009-11-06 19:23:33 -05:00
|
|
|
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix || "/", self.images_dir)
|
|
|
|
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix || "/", self.css_dir)
|
2009-10-29 12:43:08 -04:00
|
|
|
config.asset_cache_buster { false }
|
|
|
|
|
|
|
|
config.add_import_path(config.sass_dir)
|
2009-10-26 18:42:06 -04:00
|
|
|
end
|
2010-03-22 23:48:06 -04:00
|
|
|
|
2009-10-27 21:13:19 -04:00
|
|
|
configure :build do
|
|
|
|
::Compass.configuration do |config|
|
2010-03-22 23:48:06 -04:00
|
|
|
config.css_dir = File.join(File.basename(self.build_dir), self.css_dir)
|
|
|
|
config.images_dir = File.join(File.basename(self.build_dir), self.images_dir)
|
2009-10-27 21:13:19 -04:00
|
|
|
end
|
2010-09-04 23:26:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Tilt::SassPlusCSSFilenameTemplate < Tilt::SassTemplate
|
|
|
|
def sass_options
|
|
|
|
location_of_sass_file = Middleman::Base.environment == "build" ?
|
|
|
|
File.join(Middleman::Base.root, Middleman::Base.build_dir) :
|
|
|
|
Middleman::Base.public
|
|
|
|
|
|
|
|
parts = basename.split('.')
|
|
|
|
parts.pop
|
|
|
|
css_filename = File.join(location_of_sass_file, Middleman::Base.css_dir, parts.join("."))
|
|
|
|
super.merge(::Compass.configuration.to_sass_engine_options).merge(:css_filename => css_filename)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Tilt.register 'sass', Tilt::SassPlusCSSFilenameTemplate
|
|
|
|
Middleman::Renderers.register(:sass, Tilt::SassPlusCSSFilenameTemplate)
|
|
|
|
|
|
|
|
class Tilt::ScssPlusCSSFilenameTemplate < Tilt::SassPlusCSSFilenameTemplate
|
|
|
|
def sass_options
|
|
|
|
super.merge(:syntax => :scss)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Tilt.register 'scss', Tilt::ScssPlusCSSFilenameTemplate
|
|
|
|
Middleman::Renderers.register(:scss, Tilt::ScssPlusCSSFilenameTemplate)
|
|
|
|
|
|
|
|
|
|
|
|
module Middleman::Haml
|
|
|
|
module Sass
|
|
|
|
include ::Haml::Filters::Base
|
|
|
|
|
|
|
|
def render(text)
|
|
|
|
::Sass::Engine.new(text, ::Compass.configuration.to_sass_engine_options).render
|
2009-10-27 21:13:19 -04:00
|
|
|
end
|
2009-10-26 18:42:06 -04:00
|
|
|
end
|
2009-10-22 20:25:15 -04:00
|
|
|
end
|