Support Haml 4. Tests only run with Haml 4 now. Fixes #783

This commit is contained in:
Ben Hollis 2013-02-17 19:40:17 -08:00
parent aa10991b78
commit 9057b7a85e
7 changed files with 45 additions and 57 deletions

View file

@ -1,5 +1,8 @@
source :rubygems source :rubygems
# Make sure to use Haml 4 for tests
gem "haml", "~> 4.0.0"
# Build and doc tools # Build and doc tools
gem "rake", "~> 10.0.3" gem "rake", "~> 10.0.3"
gem "yard", "~> 0.8.0" gem "yard", "~> 0.8.0"
@ -13,7 +16,6 @@ gem "rspec", "~> 2.12"
# Optional middleman dependencies, included for tests # Optional middleman dependencies, included for tests
gem "sinatra" gem "sinatra"
gem "slim", "~> 1.2.0" gem "slim", "~> 1.2.0"
gem "coffee-filter", "~> 0.1.1"
gem "liquid", "~> 2.2" gem "liquid", "~> 2.2"
gem "less", "~> 2.2" gem "less", "~> 2.2"
gem "stylus", "~> 0.6.2" gem "stylus", "~> 0.6.2"

View file

@ -11,25 +11,29 @@ module Middleman
class << self class << self
# Once registered # Once registered
def registered(app) def registered(app)
app.before_configuration do
template_extensions :coffee => :js
end
# Tell Tilt to use it as well (for inline scss blocks) # Tell Tilt to use it as well (for inline scss blocks)
::Tilt.register 'coffee', DebuggingCoffeeScriptTemplate ::Tilt.register 'coffee', DebuggingCoffeeScriptTemplate
::Tilt.prefer(DebuggingCoffeeScriptTemplate) ::Tilt.prefer(DebuggingCoffeeScriptTemplate)
app.before_configuration do
template_extensions :coffee => :js
DebuggingCoffeeScriptTemplate.middleman_app = self
end
end end
alias :included :registered alias :included :registered
end end
# A Template for Tilt which outputs debug messages # A Template for Tilt which outputs debug messages
class DebuggingCoffeeScriptTemplate < ::Tilt::CoffeeScriptTemplate class DebuggingCoffeeScriptTemplate < ::Tilt::CoffeeScriptTemplate
# Make the current Middleman app accessible to the template
cattr_accessor :middleman_app
# Add exception messaging # Add exception messaging
# @param [Class] context # @param [Class] context
# @param [Hash] locals # @param [Hash] locals
# @return [String] # @return [String]
def evaluate(context, locals, &block) def evaluate(context, locals, &block)
return super if context.build? return super if middleman_app.build?
begin begin
super super

View file

@ -53,13 +53,11 @@ Feature: Minify CSS
When I go to "/inline-css.html" When I go to "/inline-css.html"
Then I should see: Then I should see:
""" """
<style type='text/css'> <style>
/*<![CDATA[*/ body {
body { test: style;
test: style; good: deal;
good: deal; }
}
/*]]>*/
</style> </style>
""" """
@ -83,7 +81,7 @@ Feature: Minify CSS
When I go to "/inline-css.html" When I go to "/inline-css.html"
Then I should see: Then I should see:
""" """
<style type='text/css'> <style>
body { body {
test: style; test: style;
good: deal; } good: deal; }
@ -108,7 +106,7 @@ Feature: Minify CSS
When I go to "/inline-css.html" When I go to "/inline-css.html"
Then I should see: Then I should see:
""" """
<style type='text/css'> <style>
Hello Hello
</style> </style>
""" """
@ -123,9 +121,7 @@ Feature: Minify CSS
When I go to "/inline-css.html" When I go to "/inline-css.html"
Then I should see: Then I should see:
""" """
<style type='text/css'> <style>
/*<![CDATA[*/ body{test:style;good:deal}
body{test:style;good:deal}
/*]]>*/
</style> </style>
""" """

View file

@ -10,15 +10,13 @@ Feature: Minify Javascript
When I go to "/inline-js.html" When I go to "/inline-js.html"
Then I should see: Then I should see:
""" """
<script type='text/javascript'> <script>
//<![CDATA[ ;(function() {
;(function() { this;
this; should();
should(); all.be();
all.be(); on = { one: line };
on = { one: line }; })();
})();
//]]>
</script> </script>
<script> <script>
;(function() { ;(function() {
@ -61,15 +59,13 @@ Feature: Minify Javascript
When I go to "/inline-js.html" When I go to "/inline-js.html"
Then I should see: Then I should see:
""" """
<script type='text/javascript'> <script>
//<![CDATA[ ;(function() {
;(function() { this;
this; should();
should(); all.be();
all.be(); on = { one: line };
on = { one: line }; })();
})();
//]]>
</script> </script>
<script> <script>
;(function() { ;(function() {
@ -110,10 +106,8 @@ Feature: Minify Javascript
When I go to "/inline-js.html" When I go to "/inline-js.html"
Then I should see: Then I should see:
""" """
<script type='text/javascript'> <script>
//<![CDATA[ Hello
Hello
//]]>
</script> </script>
<script> <script>
Hello Hello
@ -138,10 +132,8 @@ Feature: Minify Javascript
When I go to "/inline-js.html" When I go to "/inline-js.html"
Then I should see: Then I should see:
""" """
<script type='text/javascript'> <script>
//<![CDATA[ (function(){this,should(),all.be(),on={one:line}})();
(function(){this,should(),all.be(),on={one:line}})();
//]]>
</script> </script>
<script> <script>
(function(){this,should(),too()})(); (function(){this,should(),too()})();
@ -177,12 +169,11 @@ Feature: Minify Javascript
Given a fixture app "minify-js-app" Given a fixture app "minify-js-app"
And a file named "config.rb" with: And a file named "config.rb" with:
""" """
require "coffee-filter"
activate :minify_javascript, :inline => true activate :minify_javascript, :inline => true
""" """
And the Server is running at "minify-js-app" And the Server is running at "minify-js-app"
When I go to "/inline-coffeescript.html" When I go to "/inline-coffeescript.html"
Then I should see "6" lines Then I should see "3" lines
Scenario: Rendering external js (coffeescript) with the feature enabled Scenario: Rendering external js (coffeescript) with the feature enabled
Given a fixture app "minify-js-app" Given a fixture app "minify-js-app"
@ -198,8 +189,6 @@ Feature: Minify Javascript
Given a fixture app "passthrough-app" Given a fixture app "passthrough-app"
And a file named "config.rb" with: And a file named "config.rb" with:
""" """
require "coffee-filter"
module ::PassThrough module ::PassThrough
def self.compress(data) def self.compress(data)
data data
@ -214,7 +203,7 @@ Feature: Minify Javascript
""" """
And the Server is running at "passthrough-app" And the Server is running at "passthrough-app"
When I go to "/inline-coffeescript.html" When I go to "/inline-coffeescript.html"
Then I should see "16" lines Then I should see "13" lines
Scenario: Rendering external js (coffeescript) with a passthrough minifier Scenario: Rendering external js (coffeescript) with a passthrough minifier
Given a fixture app "passthrough-app" Given a fixture app "passthrough-app"

View file

@ -1 +0,0 @@
require "coffee-filter"

View file

@ -1 +0,0 @@
require "coffee-filter"

View file

@ -1,5 +1,4 @@
%style(type="text/css") :sass
:sass body
body test: style
test: style good: deal
good: deal