From 9057b7a85e7c2985e2349a5a54bb5f4622884df0 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 17 Feb 2013 19:40:17 -0800 Subject: [PATCH] Support Haml 4. Tests only run with Haml 4 now. Fixes #783 --- Gemfile | 4 +- .../middleman-core/renderers/coffee_script.rb | 14 +++-- middleman-more/features/minify_css.feature | 22 ++++---- .../features/minify_javascript.feature | 51 ++++++++----------- .../fixtures/coffeescript-app/config.rb | 1 - .../fixtures/minify-js-app/config.rb | 1 - .../source/inline-css.html.haml | 9 ++-- 7 files changed, 45 insertions(+), 57 deletions(-) diff --git a/Gemfile b/Gemfile index 3f66261a..b0be8983 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,8 @@ source :rubygems +# Make sure to use Haml 4 for tests +gem "haml", "~> 4.0.0" + # Build and doc tools gem "rake", "~> 10.0.3" gem "yard", "~> 0.8.0" @@ -13,7 +16,6 @@ gem "rspec", "~> 2.12" # Optional middleman dependencies, included for tests gem "sinatra" gem "slim", "~> 1.2.0" -gem "coffee-filter", "~> 0.1.1" gem "liquid", "~> 2.2" gem "less", "~> 2.2" gem "stylus", "~> 0.6.2" diff --git a/middleman-core/lib/middleman-core/renderers/coffee_script.rb b/middleman-core/lib/middleman-core/renderers/coffee_script.rb index 5027089c..69b141fe 100644 --- a/middleman-core/lib/middleman-core/renderers/coffee_script.rb +++ b/middleman-core/lib/middleman-core/renderers/coffee_script.rb @@ -11,25 +11,29 @@ module Middleman class << self # Once registered def registered(app) - app.before_configuration do - template_extensions :coffee => :js - end - # Tell Tilt to use it as well (for inline scss blocks) ::Tilt.register 'coffee', DebuggingCoffeeScriptTemplate ::Tilt.prefer(DebuggingCoffeeScriptTemplate) + + app.before_configuration do + template_extensions :coffee => :js + DebuggingCoffeeScriptTemplate.middleman_app = self + end end alias :included :registered end # A Template for Tilt which outputs debug messages class DebuggingCoffeeScriptTemplate < ::Tilt::CoffeeScriptTemplate + # Make the current Middleman app accessible to the template + cattr_accessor :middleman_app + # Add exception messaging # @param [Class] context # @param [Hash] locals # @return [String] def evaluate(context, locals, &block) - return super if context.build? + return super if middleman_app.build? begin super diff --git a/middleman-more/features/minify_css.feature b/middleman-more/features/minify_css.feature index eb39da6b..0c707861 100644 --- a/middleman-more/features/minify_css.feature +++ b/middleman-more/features/minify_css.feature @@ -53,13 +53,11 @@ Feature: Minify CSS When I go to "/inline-css.html" Then I should see: """ - """ @@ -83,7 +81,7 @@ Feature: Minify CSS When I go to "/inline-css.html" Then I should see: """ - """ @@ -123,9 +121,7 @@ Feature: Minify CSS When I go to "/inline-css.html" Then I should see: """ - """ \ No newline at end of file diff --git a/middleman-more/features/minify_javascript.feature b/middleman-more/features/minify_javascript.feature index 06795274..b0ca848d 100644 --- a/middleman-more/features/minify_javascript.feature +++ b/middleman-more/features/minify_javascript.feature @@ -10,15 +10,13 @@ Feature: Minify Javascript When I go to "/inline-js.html" Then I should see: """ -