diff --git a/lib/middleman/renderers/haml.rb b/lib/middleman/renderers/haml.rb index 4a3c782b..ac7ab3ee 100755 --- a/lib/middleman/renderers/haml.rb +++ b/lib/middleman/renderers/haml.rb @@ -6,36 +6,14 @@ module Middleman module Haml class << self def registered(app) - app.helpers Middleman::Renderers::Haml::Helpers + app.helpers Helpers end alias :included :registered end module Helpers def haml_partial(name, options = {}) - partial(name, options) - end - end - - module Table - include ::Haml::Filters::Base - - def render(text) - output = '
' - line_num = 0 - text.each_line do |line| - line_num += 1 - next if line.strip.empty? - output << %Q{} - - columns = line.split("|").map { |p| p.strip } - columns.each_with_index do |col, i| - output << %Q{} - end - - output << "" - end - output + "
#{col}
" + render(name, options) end end end diff --git a/lib/middleman/renderers/sass.rb b/lib/middleman/renderers/sass.rb index 88e19377..3dc8a1fd 100644 --- a/lib/middleman/renderers/sass.rb +++ b/lib/middleman/renderers/sass.rb @@ -9,17 +9,17 @@ module Middleman class << self def registered(app) app.after_feature_init do - views_root = File.basename(self.views) + views_root = File.basename(app.views) ::Compass.configuration do |config| config.cache = false # For sassc files - config.project_path = self.root - config.sass_dir = File.join(views_root, self.css_dir) + config.project_path = app.root + config.sass_dir = File.join(views_root, app.css_dir) config.output_style = :nested - config.fonts_dir = File.join(views_root, self.fonts_dir) - config.css_dir = File.join(views_root, self.css_dir) - config.images_dir = File.join(views_root, self.images_dir) - 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) + config.fonts_dir = File.join(views_root, app.fonts_dir) + config.css_dir = File.join(views_root, app.css_dir) + config.images_dir = File.join(views_root, app.images_dir) + config.http_images_path = app.http_images_path rescue File.join(app.http_prefix || "/", app.images_dir) + config.http_stylesheets_path = app.http_css_path rescue File.join(app.http_prefix || "/", app.css_dir) config.asset_cache_buster :none config.add_import_path(config.sass_dir) @@ -36,48 +36,53 @@ module Middleman end alias :included :registered end + + class SassPlusCSSFilenameTemplate < ::Tilt::SassTemplate + def sass_options + return super if basename.nil? + + location_of_sass_file = Middleman::Server.environment == :build ? + File.join(Middleman::Server.root, Middleman::Server.build_dir) : + Middleman::Server.views + + parts = basename.split('.') + parts.pop + css_filename = File.join(location_of_sass_file, Middleman::Server.css_dir, parts.join(".")) + super.merge(::Compass.configuration.to_sass_engine_options).merge(:css_filename => css_filename) + end + + def evaluate(scope, locals, &block) + begin + super + rescue Sass::SyntaxError => e + Sass::SyntaxError.exception_to_css(e, :full_exception => true) + end + end + end + ::Tilt.register 'sass', SassPlusCSSFilenameTemplate + ::Tilt.prefer(SassPlusCSSFilenameTemplate) + + class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate + def sass_options + super.merge(:syntax => :scss) + end + end + ::Tilt.register 'scss', ScssPlusCSSFilenameTemplate + ::Tilt.prefer(ScssPlusCSSFilenameTemplate) end end end -class Tilt::SassPlusCSSFilenameTemplate < Tilt::SassTemplate - def sass_options - return super if basename.nil? - - location_of_sass_file = Middleman::Server.environment == :build ? - File.join(Middleman::Server.root, Middleman::Server.build_dir) : - Middleman::Server.views - - parts = basename.split('.') - parts.pop - css_filename = File.join(location_of_sass_file, Middleman::Server.css_dir, parts.join(".")) - super.merge(::Compass.configuration.to_sass_engine_options).merge(:css_filename => css_filename) - end - - def evaluate(scope, locals, &block) - begin - super - rescue Sass::SyntaxError => e - Sass::SyntaxError.exception_to_css(e, :full_exception => true) - end - end -end -Tilt.register 'sass', Tilt::SassPlusCSSFilenameTemplate - -class Tilt::ScssPlusCSSFilenameTemplate < Tilt::SassPlusCSSFilenameTemplate - def sass_options - super.merge(:syntax => :scss) - end -end -Tilt.register 'scss', Tilt::ScssPlusCSSFilenameTemplate - - +# Use compass settings in Haml filters +# Other, tilt-based filters (like those used in Slim) will +# work automatically. module Middleman::Renderers::Haml module Sass include ::Haml::Filters::Base def render(text) - ::Sass::Engine.new(text, ::Compass.configuration.to_sass_engine_options).render + compass_options = ::Compass.configuration.to_sass_engine_options + ::Sass::Engine.new(text, compass_options).render end end end \ No newline at end of file