Stylus support and tests. Fixes #649
This commit is contained in:
parent
1bfd077d00
commit
01e9c336b0
1
Gemfile
1
Gemfile
|
@ -30,6 +30,7 @@ group :test do
|
||||||
end
|
end
|
||||||
|
|
||||||
gem "less", "~> 2.2"
|
gem "less", "~> 2.2"
|
||||||
|
gem "stylus"
|
||||||
end
|
end
|
||||||
|
|
||||||
gem "middleman-sprockets", :github => "middleman/middleman-sprockets"
|
gem "middleman-sprockets", :github => "middleman/middleman-sprockets"
|
||||||
|
|
|
@ -68,6 +68,13 @@ module Middleman
|
||||||
app.register Middleman::Renderers::Less
|
app.register Middleman::Renderers::Less
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Stylus Support
|
||||||
|
begin
|
||||||
|
require "middleman-core/renderers/stylus"
|
||||||
|
app.register Middleman::Renderers::Stylus
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :included :registered
|
alias :included :registered
|
||||||
|
|
28
middleman-core/lib/middleman-core/renderers/stylus.rb
Normal file
28
middleman-core/lib/middleman-core/renderers/stylus.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
require "stylus"
|
||||||
|
require "stylus/tilt"
|
||||||
|
|
||||||
|
module Middleman
|
||||||
|
module Renderers
|
||||||
|
|
||||||
|
# Sass renderer
|
||||||
|
module Stylus
|
||||||
|
|
||||||
|
# Setup extension
|
||||||
|
class << self
|
||||||
|
|
||||||
|
# Once registered
|
||||||
|
def registered(app)
|
||||||
|
# Default less options
|
||||||
|
app.set :styl, {}
|
||||||
|
|
||||||
|
app.before_configuration do
|
||||||
|
template_extensions :styl => :css
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
alias :included :registered
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
55
middleman-more/features/stylus.feature
Normal file
55
middleman-more/features/stylus.feature
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
@nojava
|
||||||
|
Feature: Stylus Updates and Partials
|
||||||
|
Scenario: The preview server should update stylesheets when Stylus changes
|
||||||
|
Given the Server is running at "stylus-preview-app"
|
||||||
|
And the file "source/stylesheets/plain.css.styl" has the contents
|
||||||
|
"""
|
||||||
|
red
|
||||||
|
color: #f0f0f0
|
||||||
|
"""
|
||||||
|
When I go to "/stylesheets/plain.css"
|
||||||
|
Then I should see "color: #f0f0f0;"
|
||||||
|
And the file "source/stylesheets/plain.css.styl" has the contents
|
||||||
|
"""
|
||||||
|
red
|
||||||
|
color: #0f0f0f
|
||||||
|
"""
|
||||||
|
When I go to "/stylesheets/plain.css"
|
||||||
|
Then I should see "color: #0f0f0f;"
|
||||||
|
|
||||||
|
Scenario: The preview server should update stylesheets when Stylus partials change
|
||||||
|
Given the Server is running at "stylus-preview-app"
|
||||||
|
And the file "source/stylesheets/main.css.styl" has the contents
|
||||||
|
"""
|
||||||
|
@import '_partial'
|
||||||
|
|
||||||
|
red
|
||||||
|
color: #f0f0f0
|
||||||
|
"""
|
||||||
|
And the file "source/stylesheets/_partial.styl" has the contents
|
||||||
|
"""
|
||||||
|
body
|
||||||
|
font-size: 14px
|
||||||
|
"""
|
||||||
|
When I go to "/stylesheets/main.css"
|
||||||
|
Then I should see "color: #f0f0f0;"
|
||||||
|
And I should see "font-size: 14px;"
|
||||||
|
And the file "source/stylesheets/main.css.styl" has the contents
|
||||||
|
"""
|
||||||
|
@import '_partial'
|
||||||
|
|
||||||
|
red
|
||||||
|
color: #0f0f0f
|
||||||
|
"""
|
||||||
|
And the file "source/stylesheets/_partial.styl" has the contents
|
||||||
|
"""
|
||||||
|
body
|
||||||
|
font-size: 18px
|
||||||
|
"""
|
||||||
|
When I go to "/stylesheets/main.css"
|
||||||
|
Then I should see "color: #0f0f0f;"
|
||||||
|
And I should see "font-size: 18px"
|
||||||
|
|
||||||
|
Scenario: Stylus partials should work when building
|
||||||
|
Given a successfully built app at "stylus-preview-app"
|
||||||
|
Then the file "build/stylesheets/main.css" should contain "font-size: 18px"
|
|
@ -0,0 +1 @@
|
||||||
|
Hola Mundo
|
|
@ -0,0 +1 @@
|
||||||
|
<%= yield %>
|
|
@ -0,0 +1,2 @@
|
||||||
|
body
|
||||||
|
font-size: 18px
|
|
@ -0,0 +1,2 @@
|
||||||
|
body
|
||||||
|
font-size: 18px
|
|
@ -0,0 +1,4 @@
|
||||||
|
@import '_partial'
|
||||||
|
|
||||||
|
red
|
||||||
|
color: blue
|
|
@ -0,0 +1,4 @@
|
||||||
|
//= require "_partial2.css.styl"
|
||||||
|
|
||||||
|
red
|
||||||
|
color: blue
|
|
@ -0,0 +1,2 @@
|
||||||
|
red
|
||||||
|
color: blue
|
Loading…
Reference in a new issue